cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L412 Issue with ADC

Aj_123
Associate II

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 discussion is locked. Please start a new topic to ask your question.
9 REPLIES 9
TDK
Super User

> 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.

If you feel a post has answered your question, please click "Accept as Solution".
Billy OWEN
ST Employee

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

AScha.3
Super User

>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

 

If you feel a post has answered your question, please click "Accept as Solution".

CDR.pngCDR_error.png

Aj_123
Associate II

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.

 

Aj_123
Associate II

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

TDK
Super User

The common ADC register is at ADC12_COMMON->CDR, not ADC1->CDR.

https://github.com/STMicroelectronics/cmsis_device_l4/blob/013bf0e41256ffbc2b539676f2007d08b297a86a/Include/stm32l412xx.h#L976C9-L976C29

 

If you feel a post has answered your question, please click "Accept as Solution".
Aj_123
Associate II

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

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;
If you feel a post has answered your question, please click "Accept as Solution".