PSOC Die Temp

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
wistc_299286
Level 3
Level 3
10 replies posted 10 sign-ins First solution authored

 

I'm really struggling to get the  die temp working for the SAR in the PSOC6. I've looked at the example project and the other post on the forums. I'm not able to easily intergrade those examples into my project. 

The steps to switch configurations between my application settings and the settings for the die temp are not clear.  It's not as simple as just changing the P1 switch in the MUX registers. I have tried creating multiple configurations in my code and switching between them as shown in the CE220974, but I am not able to successfully switch to the die temp. I have spent several days trying to get this to work. 

Can any one list the steps needed to use the die temp or a working SAR configuration that I can switch to?

The SAR on the PSOC is quite complex and I really wish with there was an API to set up the Die temp and switch between a working die configuration and my application. 

Currently, in my code I'm just checking if the conversion is done in the main loop (no interrupts at the moment) and then after getting the result I switch over to the next configuration back and forth. For the die temp configuration I'm using the defined configuration in the example project.  

0 Likes
1 Solution
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi,

The newer version of PDL will have inbuilt API's for ADC count conversion for temperature calculation.

Best Regards,
Vasanth

View solution in original post

0 Likes
3 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi,

For the die temp to work as expected,

  • ADC resolution of 12 bits
  • Data format right justified
  • Make sure that you use band gap reference as the VREF for ADC
  • You are using Averaging(256 ideal) for the channel die temp is connected to
  • Acquisition time atleast 5us
  • Sample rate less than 100ksps
  • Single ended channel with Vneg connected to VSS

Best Regards,
Vasanth

 

0 Likes

Hello Vasanth,

Thank you for the fast reply and for looking into my issue. I have created a SAR hardware configuration which is directly copied from the CE220974 example project.  From what I can tell, it looks like it has some of those settings already configured. It's difficult to know since I have to initialize the structure in code without a GUI implementation, so I feel like I'm shooting in the dark a bit like with PSOC1. 

Here is my structure ( the forum won't let me attach my .h file) :

/*******************************************************************************
* Constants for configuring Config1 of the Scan_ADC
*******************************************************************************/
/* Enable only channel 0. */
#define CONFIG1_CHAN_EN (1u)

/* Channel 0 is single ended.
* Aperture time is set by Sample Time 0.
* The DieTemp sensor is connected on the SARMUX_VIRT port at PIN_ADDR 0.
* The sensor is enabled once connection to the SAR ADC is made.
* Averaging is enabled. */
#define CONFIG1_CHAN0_CONFIG (CY_SAR_CHAN_SINGLE_ENDED \
| CY_SAR_CHAN_SAMPLE_TIME_0 \
| CY_SAR_POS_PORT_ADDR_SARMUX_VIRT \
| CY_SAR_CHAN_POS_PIN_ADDR_0 \
| CY_SAR_CHAN_AVG_ENABLE)

/* Single ended channels are signed.
* Averaging mode is set to sequential fixed with 32 samples of averaging. */
#define CONFIG1_SAMPLE_CTRL (CY_SAR_SINGLE_ENDED_SIGNED \
| CY_SAR_AVG_CNT_32 \
| CY_SAR_AVG_MODE_SEQUENTIAL_FIXED)

/* Channels 1 through 15 are unconfigured. */
#define CONFIG1_CHAN_CONFIG {(uint32_t)CONFIG1_CHAN0_CONFIG \
, 0uL, 0uL,0uL,0uL,0uL,0uL,0uL,0uL,0uL,0uL,0uL,0uL,0uL,0uL,0uL}

/* Enable the End of Scan interrupt only. */
#define CONFIG1_INTR_MASK (CY_SAR_INTR_EOS_MASK)

/* Use the internal 1.2 V bandgap reference for the SAR reference source.
* Enable the bypass capacitor connection.
* Connect the negative terminal for single ended channels to VSSA. */
#define CONFIG1_VREF_MV_VALUE (1200uL)
#define CONFIG1_CTRL (CY_SAR_VREF_SEL_BGR \
| CY_SAR_BYPASS_CAP_ENABLE \
| CY_SAR_NEG_SEL_VSSA_KELVIN)

/* Config1 will operate in single shot mode.
* Set the sample time to meet the DieTemp settling time requirement of 1 us.
* With a 16.67 MHz SAR clock, 17 cycles (or a value of 18 in the register)
* gives an aperture time of 1.02 us. */
#define CONFIG1_SAMPLE_TIME01 ((18 << CY_SAR_SAMPLE_TIME0_SHIFT) \
| (4 << CY_SAR_SAMPLE_TIME1_SHIFT))

/* Set the sample times for 2 and 3 to be 4 clock cycles.
* Note that these two sample times are not used by any channels and only shown for reference. */
#define CONFIG1_SAMPLE_TIME23 ((4 << CY_SAR_SAMPLE_TIME2_SHIFT) \
| (4 << CY_SAR_SAMPLE_TIME3_SHIFT))

/* Set the initial state of switches.
* Close the switch between the DieTemp sensor and the positive terminal of the SAR (TEMP_VPLUS).
* Close the switch between VSSA and the negative terminal of the SAR (VSSA_VMINUS). */
#define CONFIG1_MUX_SWITCH0 (CY_SAR_MUX_FW_VSSA_VMINUS \
| CY_SAR_MUX_FW_TEMP_VPLUS)

/* Enable sequencer control for the VSSA and TEMP switches.
* While unnecessary in this design because there is only one channel in Config1,
* the code is provided for reference for designs with multiple channels. */
#define CONFIG1_MUX_SWITCH_SQ_CTRL (CY_SAR_MUX_SQ_CTRL_VSSA \
| CY_SAR_MUX_SQ_CTRL_TEMP)

/* Define the initialization structure for ADC stucture Config1. */
#define ADC_DIE_TEMP_CONFIG const cy_stc_sar_config_t Die_Temp_ADC_config = \
{ \
.ctrl = (uint32_t)CONFIG1_CTRL, \
.sampleCtrl = (uint32_t)CONFIG1_SAMPLE_CTRL, \
.sampleTime01 = CONFIG1_SAMPLE_TIME01, \
.sampleTime23 = CONFIG1_SAMPLE_TIME23, \
.rangeThres = CY_SAR_DEINIT, \
.rangeCond = CY_SAR_RANGE_COND_BELOW, \
.chanEn = CONFIG1_CHAN_EN, \
.chanConfig = CONFIG1_CHAN_CONFIG, \
.intrMask = CONFIG1_INTR_MASK, /* */ \
.satIntrMask = CY_SAR_DEINIT, /* Disable the saturation interrupt. */ \
.rangeIntrMask = CY_SAR_DEINIT, /* Disable the range interrupt. */ \
.muxSwitch = CONFIG1_MUX_SWITCH0, \
.muxSwitchSqCtrl = CONFIG1_MUX_SWITCH_SQ_CTRL, \
.configRouting = true, \
.vrefMvValue = CONFIG1_VREF_MV_VALUE, \
}

 

I then switch to the Die Temp configuration here in main:

wistc_299286_0-1633101121457.png

wistc_299286_1-1633101314245.png

 

Here I am just switching from the GUI config to the die temp config. I have disabled switching back to the original configuration for the moment ( and as you can see with my commented code I have tried multiple combinations of starting and stop conversions, de-intializing the config, and with both continuous mode and single shot). What happens is that I get one successful conversion with the original GUI configuration, but all conversion stops when I initialize the Die temp configuration. It also doesn't work when I switch back to the working configuration. I am monitoring the raw ADC results over I2C. 

 

 

 

Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi,

The newer version of PDL will have inbuilt API's for ADC count conversion for temperature calculation.

Best Regards,
Vasanth

0 Likes