AnsweredAssumed Answered

STM32F373 SDADC Calibration hardfault

Question asked by subrt.stanislav on Oct 3, 2014
Latest reply on Feb 10, 2016 by Salazar.Christian

I would like to kindly ask for a help with calibration of SDADC peripheral on chip STM32F373.
Im using SDADC with TIM19 triggered conversions 1000Hz.

 I have tried two variants of calibration
    /* Set CALIBCNT[1:0] bits in SDADC_CR2 register */
    Converter.Instance->CR2 &= ~(SDADC_CR2_CALIBCNT);
    Converter.Instance->CR2 |= SDADC_CALIBRATION_SEQ_1;

    /* Set STARTCALIB in SDADC_CR2 */
    Converter.Instance->CR2 |= SDADC_CR2_STARTCALIB;

    while( ( Converter.Instance->ISR & SDADC_ISR_EOCALF ) != SDADC_ISR_EOCALF ){
    Converter.Instance->CLRISR |= SDADC_ISR_CLREOCALF;
    //Start calibration in polling mode
    HAL_SDADC_CalibrationStart(&Converter, SDADC_CALIBRATION_SEQ_1);
    //Poll for the end of calibration
    HAL_SDADC_PollForCalibEvent(&Converter, HAL_MAX_DELAY);

Both of these variants end with hard fault. Code hits polling cycle for EOCALF and then hardfault occurs. When I comment polling part everything works well and end of conversion interrupt gets fired every 1ms, data can be read from data register... only this calibration polling jumps to hardfault.

I have noticed that if I set a breakpoint just one step after calibration start and than hit continue, no hardfault occurs... If I place waiting code for(int i=0; i<10000;i++); it jumps to hardfault as well.

Could anybody give me an advice what am I doing wrong?

With best regards

Stanislav Subrt

EDIT1: Oh have found workaround... setting up an end of calibration interrupt and clearing calibration flags in here. So interrupt mode works ok but im still confused what is going on in polling mode. Hope it helps.