STM32F051 ADC problem with CHIBIOS 2.6.6

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
carlo
Posts: 2
Joined: Wed May 28, 2014 10:37 am

STM32F051 ADC problem with CHIBIOS 2.6.6

Post by carlo »

Hello to all,
I just moved my project from CHIBIOS 2.6.5 to 2.6.6 and now I have a problem with the ADC initialization.
When I start the ADC1 the system get stuck on on ADCStart, failing on :

Code: Select all

chDbgAssert((adcp->state == ADC_STOP) || (adcp->state == ADC_READY),
              "adcStart(), #1", "invalid state")


I'm starting the ADC1 from a thread, below there's my code:

Code: Select all


static const ADCConversionGroup adcgrpcfg1 = {
    FALSE,
    ADC_GRP1_NUM_CHANNELS,
    NULL,
    NULL,
    ADC_CFGR1_RES_12BIT,                              /* CFGRR1 */
    ADC_TR(0, 0),                                     /* TR */
    ADC_SMPR_SMP_1P5,                                 /* SMPR */
    ADC_CHSELR_CHSEL4            /* CHSELR */
};

static void Start_InternalTmpMeasurement(void)
{
  chThdCreateStatic(adc_th1, sizeof(adc_th1), LOWPRIO +1, refTmpThd, NULL);
}

static msg_t refTmpThd(void *arg) {

  (void)arg;
  chRegSetThreadName("REF_TMP_THD");
  uint32_t adc_raw, temp, i;
  uint32_t acc = 0;
  while (TRUE)
  {
    adcStart(&ADCD1, NULL);
    adcStartConversion(&ADCD1, &adcgrpcfg1, adcSampleBuf, ADC_GRP1_BUF_DEPTH);
    .....


And from "mcuconf.h" :

Code: Select all

#define STM32F0xx_MCUCONF

/*
 * HAL driver system settings.
 */
#define STM32_NO_INIT                       FALSE
#define STM32_PVD_ENABLE                    FALSE
#define STM32_PLS                           STM32_PLS_LEV0
#define STM32_HSI_ENABLED                   FALSE
#define STM32_HSE_ENABLED                   TRUE
#define STM32_HSI14_ENABLED                 FALSE
#define STM32_LSI_ENABLED                   FALSE
#define STM32_LSE_ENABLED                   FALSE
#define STM32_SW                            STM32_SW_PLL
#define STM32_PLLSRC                        STM32_PLLSRC_HSE
#define STM32_PREDIV_VALUE                  1
#define STM32_PLLMUL_VALUE                  6
#define STM32_HPRE                          STM32_HPRE_DIV1
#define STM32_PPRE                          STM32_PPRE_DIV2
#define STM32_ADCSW                         STM32_ADCSW_PCLK
#define STM32_MCOSEL                        STM32_MCOSEL_NOCLOCK
#define STM32_ADCPRE                        STM32_ADCPRE_DIV4
#define STM32_CECSW                         STM32_CECSW_LSE
#define STM32_I2C1SW                        STM32_I2C1SW_SYSCLK
#define STM32_USART1SW                      STM32_USART1SW_PCLK
#define STM32_HAS_RTC                       TRUE
#define STM32_RTCSEL                        STM32_RTCSEL_HSEDIV

/*
 * ADC driver system settings.
 */
#define STM32_ADC_USE_ADC1                  TRUE
#define STM32_ADC_ADC1_DMA_PRIORITY         2
#define STM32_ADC_IRQ_PRIORITY              2
#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY     2



I read that ADC driver has been reviewed in 2.6.6 release, maybe I forgot to define something...
Thank you in advance,

Carlo Ferraresi
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F051 ADC problem with CHIBIOS 2.6.6

Post by Giovanni »

Hi,

There has been a change into the ADC drivers, you need to specify ADC_CFGR1_CONT in the configuration structure. See the demo under ./testhal/STM32F0xx/ADC for an example.

Giovanni
carlo
Posts: 2
Joined: Wed May 28, 2014 10:37 am

Re: STM32F051 ADC problem with CHIBIOS 2.6.6

Post by carlo »

Thank you, I completely missed the ADC_CFGR1_CONT even if I looked at the demo. :cry:

Carlo
Post Reply