cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WBA55CG stuck if ADC4 Channel 2 used with BLE and internal temperature calibration

jpepv
Associate II

I am using the BLE_p2p_Server_ext example on a stm32wba55cg and i want to use ADC_Channel_2 as a way of voltage measurements.

My current setup:

I use a new adc handle:

ADCCTRL_Handle_t adc_channel2_handle =
{
  .Uid = 2,
  .State = ADCCTRL_HANDLE_NOT_REG,
  .InitConf =
  {
    .ClockPrescaler = ADC_CLOCK_ASYNC_DIV1,
    .Resolution = ADC_RESOLUTION_12B,
    .DataAlign = ADC_DATAALIGN_RIGHT,
    .ScanConvMode = ADC_SCAN_DISABLE,
    .EOCSelection = ADC_EOC_SINGLE_CONV,
    .LowPowerAutoPowerOff = DISABLE,
    .LowPowerAutonomousDPD = ADC_LP_AUTONOMOUS_DPD_DISABLE,
    .LowPowerAutoWait = DISABLE,
    .ContinuousConvMode = DISABLE,
    .NbrOfConversion = 1,
    .ExternalTrigConv = ADC_SOFTWARE_START,
    .ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE,
    .DMAContinuousRequests = DISABLE,
    .TriggerFrequencyMode = ADC_TRIGGER_FREQ_LOW,
    .Overrun = ADC_OVR_DATA_OVERWRITTEN,
    .SamplingTimeCommon1 = ADC_SAMPLETIME_814CYCLES_5,
    .SamplingTimeCommon2 = ADC_SAMPLETIME_1CYCLE_5,
    .OversamplingMode = DISABLE,
  },
  .ChannelConf =
  {
    .Channel = ADC_CHANNEL_2,
    .Rank = ADC_REGULAR_RANK_1,
    .SamplingTime = ADC_SAMPLINGTIME_COMMON_1
  }
};

and add a new task id to my task_id_list:

CFG_TASK_VOLT_MEAS

I register the new task to my sequencer:

UTIL_SEQ_RegTask(1U << CFG_TASK_VOLT_MEAS, UTIL_SEQ_RFU, MyVoltageReadTask);

and I have a timer that wakes my device every ~30 seconds. I then set the task as active:

UTIL_SEQ_SetTask(1U << CFG_TASK_VOLT_MEAS, CFG_SEQ_PRIO_0);

this is my MyVoltageReadTask:

void MyVoltageReadTask(void)
{
  uint16_t adc_value_raw = 0;
  ADCCTRL_Cmd_Status_t Cmd_Status = ADCCTRL_UNKNOWN;
  // Pause BLE temp task to avoid conflict
  UTIL_SEQ_PauseTask(1U << CFG_TASK_TEMP_MEAS);

  /* Enter limited critical section : disable all the interrupts with priority higher than RCC one
   * Concerns link layer interrupts (high and SW low) or any other high priority user system interrupt
   */
  UTILS_ENTER_LIMITED_CRITICAL_SECTION(RCC_INTR_PRIO<<4);
 
  /* Request ADC IP activation */
  Cmd_Status = ADCCTRL_RequestIpState(&adc_channel2_handle, ADC_ON);

  /* Get temperature from ADC dedicated channel */
  Cmd_Status = ADCCTRL_RequestRawValue(&adc_channel2_handle, &adc_value_raw);

  /* Request ADC IP deactivation */
  Cmd_Status = ADCCTRL_RequestIpState(&adc_channel2_handle, ADC_OFF);

  /* Exit limited critical section */
  UTILS_EXIT_LIMITED_CRITICAL_SECTION();

  // Resume BLE temp task
  UTIL_SEQ_ResumeTask(1U << CFG_TASK_TEMP_MEAS);

  // Do some calculation with the adc value...
}

that process works and I can receive the adc value via advertisement on a different device.  At -20°C and +50°C I have no problem. However if I use my stm32wba55cg at a temperature around 0°C it gets stuck and it stops advertising. I have multiple boards with the stm32wba55cg and all behave the same around that 0°C.

The only way to get it out of that is by resetting it externally or with a watchdog. Then it works for a undefined period of time until it gets stuck again.

If I remove the task from the sequencer and do nothing else with ADC4 everything works fine, even at those temperatures.

Does anyone else have issues with using ADC4 if temperature calibration is enabled or am I missing something?

Any help appreciated.

0 REPLIES 0