Skip to main content
Graduate
February 12, 2024
Question

STM32L412 Issue with ADC

  • February 12, 2024
  • 5 replies
  • 4453 views

I'm finding difficult to get the value from the channel that i configured of a regular channel with stm32l412 microcontroller. where I'm not getting the EOC interrupt enabled in ADC_ISR register. 

and When I tried to get data from ADC_CDR register, it throwing error on me like there no like this register is exists.

Really not understood why is happening like this.

Please help me in this.

    This topic has been closed for replies.

    5 replies

    Super User
    February 12, 2024

    > When I tried to get data from ADC_CDR register, it throwing error on me like there no like this register is exists.

    Show the error.

    Typically you read from the ADCx_DR register for a single ADC.

    Lots of examples in CubeMX on how to use the ADC.

    Aj_123Author
    Graduate
    February 14, 2024

    Please have a look into this. I'm trying to enable both regular and injected in ADC_CCR register so, we have to read from ADC_CDR regiser. Your help will be greatly appreciated. RM_CDR.png

    ST Employee
    February 13, 2024

    Hi @Aj_123 

     

    The forum moderator had marked your post as needing a little more investigation and direct support. An online support case has been created on your behalf, please stand by for just a moment and you will hear from us.

     

    Regards,

    Billy

    Super User
    February 13, 2024

    >When I tried to get data from ADC_CDR register

    How did you try ?

    ADC_CDR is 32 bits and has two parts...

    AScha3_0-1707849558606.png

     

    Aj_123Author
    Graduate
    February 14, 2024

    CDR.pngCDR_error.png

    Aj_123Author
    Graduate
    February 14, 2024

    This is how i tried but, i don't know why it's happening. I have not even seen CDR register is there in registers list. Please acknowledge and respond. Your help will be greatly appreciated.

     

    Super User
    February 14, 2024
    Aj_123Author
    Graduate
    February 14, 2024

    could you give me an example of this logic to read data from it .

    Super User
    February 14, 2024

    I don't know that it has the data you want, but here is how you would read the two fields in the register:

    uint32_t cdr = ADC12_COMMON->CDR;
    uint16_t upper_field = cdr >> 16;
    uint16_t lower_field = cdr & 0xFFFF;