cancel
Showing results for 
Search instead for 
Did you mean: 

SPC58EN84C3 ADC test channel initialize error.

sonerb
Associate II

I tried to initialize test channels on SARADC_B (supervisor).

/* Channels Configurations (DMA is not used)*/
static channelConfig _saradcconf_ch_configs[SPC5_SARADC_MAX_NUMOFCHANNELS] =
{
  {SARADC_CHANNEL_TEST, 96U,SARADC_REFERENCE_DEFAULT, SARADC_PRECHARGE_ENABLED, SARADC_CTR0, SARADC_WATCHDOG_REGISTER_NONE,NULL},
  {SARADC_CHANNEL_TEST, 97U,SARADC_REFERENCE_DEFAULT, SARADC_PRECHARGE_ENABLED, SARADC_CTR0, SARADC_WATCHDOG_REGISTER_NONE,NULL},
  {SARADC_CHANNEL_TEST, 98U,SARADC_REFERENCE_DEFAULT, SARADC_PRECHARGE_ENABLED, SARADC_CTR0, SARADC_WATCHDOG_REGISTER_NONE,NULL},
  {SARADC_CHANNEL_TEST, 99U,SARADC_REFERENCE_DEFAULT, SARADC_PRECHARGE_ENABLED, SARADC_CTR0, SARADC_WATCHDOG_REGISTER_NONE,NULL},
  {0U, 0U, 0U, 0U, 0U, 0xFFU, NULL},  /* Channel Configuration Unused 4 */
  {0U, 0U, 0U, 0U, 0U, 0xFFU, NULL},  /* Channel Configuration Unused 5 */
};
 
 
/**
 * @brief   Structure defining the configuration "saradcconf".
 */
SARADCConfig saradc_config_saradcconf = {
   /* conversion mode */
  SARADC_MODE_ONESHOT,
  
  /* Trigger Mode */
  SARADC_TRIGGER_DISABLED,
  
  /* CTR registers configuration (CRES,PRECHG,INPSAMP) */
  {
  /* CTR0 */ {SARADC_CRES_HIGH, 1U, 100U},
  /* CTR1 */ {SARADC_CRES_HIGH, 1U, 100U},
  /* CTR2 */ {SARADC_CRES_HIGH, 1U, 100U},
  /* CTR3 */ {SARADC_CRES_HIGH, 1U, 100U},
  },
  /* No DMA configuration */
  FALSE,
  {0U, 0U, 0U, 0U, 0U, 0U, 0U},
  NULL,
  
  /* Channels Configurations */
  _saradcconf_ch_configs,
  
  /* Number of channels */
  4U,
  
  /* Conversion callback */
  saradcconf_conv_cb,
 
  /* No analog watchdog configured */
  {
  {(float)0,(float)0},
  },
  (float)0,
  0U,
};

saradc_lld_start(&SARADC12DSV, &saradc_config_saradcconf);

While debugging I realized it goes to '.unhandled_exception2' when I tried to set TCDR[x].B.PCE (precharge bit.)

I tried to set all precharge disabled and enabled, but it still not working.

Here are some screenshots from debug view.

0693W00000WKz9qQAD.png0693W00000WKz4cQAD.png0693W00000WKz9CQAT.png0693W00000WKz92QAD.png 

2 REPLIES 2
Erwan YVIN
ST Employee

Hello ,

Which compiler do you use ?

Could you try to compile this part of code in -O0 ?

Best Regards

Erwan

sonerb
Associate II

0693W00000WL0ViQAL.pngI use FreeGCC.

I already built with -O0