#13 ADC conversion doesn't start automatically

closed
None
3
2010-12-19
2010-12-07
barthess
No

ADC conversion doesn't start automatically. Problem in os/hal/platforms/STM32/adc_lld.c file. For start you must write ADC_CR2_ADON bit in ADC1->CR2 ones more.

STM32 manual says:
"Conversion starts when ADON bit is set for a second time by software after ADC power-up time"

I have create and attach the patch. But may be I misunderstood something (I'm newbie)

Discussion

1 2 > >> (Page 1 of 2)
  • barthess
    barthess
    2010-12-07

    patch

     
    Attachments
    • assigned_to: nobody --> gdisirio
    • status: open --> open-postponed
     
  • Hello,

    The line

    /* ADC start.*/
    adcp->ad_adc->CR2 |= ADC_CR2_SWSTART | ADC_CR2_EXTTRIG;

    does write ADC_CR2_ADON a 2nd time even if the bit is not shown explicitly, the ADON bit is read from the CR2 register and then rewritten,

    Are you experiencing some specific problem with the driver?

     
  • barthess
    barthess
    2010-12-08

    main.c for ARMCM3-STM32F103-GCC demo that reproduce the bug

     
    Attachments
  • barthess
    barthess
    2010-12-08

    Hello.

    Yes, I have problems with the driver.

    ADC works only with my patch or if I manually set ADC_CR2_ADON bit after the adcStartConversion() function. I have attached file that reproduce the bug.

     
  • I see.

    The only difference I found with the ADC test demo is in the initialization structure. The demo also specifies ADC_CR2_EXTSEL_SWSTART into the CR2 configuration field, see the file ./testhal/STM32/ADC/main.c. The flag is required for software-triggered conversions.

    Can you verify if adding that flag fixes your problem?

    The current implementation implicitly uses the EXTTRIG flag that also requires that ADC_CR2_EXTSEL_SWSTART.

    Probably would be a good idea to not enforce EXTTRIG and leave that to the configuration structure. The start code would be similar to your patch. I'll have to make some tests and think about this.

     
  • In the meanwhile I move the ticket in accepted state.

     
    • status: open-postponed --> open-accepted
     
  • barthess
    barthess
    2010-12-08

    Yes, adding this flag fixes my problem.

    I haven't find the ADC demo and have write code from scratch. This was my fault.

     
    • priority: 5 --> 3
     
1 2 > >> (Page 1 of 2)