cancel
Showing results for 
Search instead for 
Did you mean: 

About STMCWB ADC issue

Longhua
Visitor

I used MC_SDK_6.3.2 to generate a motor control program, but found that sometimes the motherboard crashes. Debugging found that the following code has problems. May I ask why this is? Is it a hardware bug?

//The problematic code is here, and the program will enter a dead loop: 

while (LL_ADC_IsActiveFlag_EOCS(RCM_handle_array[handle]->regADC) == 0u)
{
    /* Nothing to do */
}

The complete code is as follows:

uint16_t RCM_ExecRegularConv (RegConv_t *regConv)
{
  uint16_t retVal;
  uint8_t handle = regConv->convHandle;
  LL_ADC_REG_SetSequencerRanks(RCM_handle_array[handle]->regADC,
                               LL_ADC_REG_RANK_1,
                               __LL_ADC_DECIMAL_NB_TO_CHANNEL(RCM_handle_array[handle]->channel));

  (void)LL_ADC_REG_ReadConversionData12L(RCM_handle_array[handle]->regADC);
  /* Bit banding access equivalent to LL_ADC_REG_StartConversionSWStart */
  BB_REG_BIT_SET(&RCM_handle_array[handle]->regADC->CR2, ADC_CR2_SWSTART_Pos);
  /* Wait until end of regular conversion */
  while (LL_ADC_IsActiveFlag_EOCS(RCM_handle_array[handle]->regADC) == 0u)
  {
    /* Nothing to do */
  }
  retVal = LL_ADC_REG_ReadConversionData12L(RCM_handle_array[handle]->regADC);
  return (retVal);
}
0 REPLIES 0