cancel
Showing results for 
Search instead for 
Did you mean: 

ADC injected group conversion

david11
Associate

In the R3_2_GetPhaseCurrents(), the following line reads the ADC data register.

hReg1 = *pHandle->pParams_str->ADCDataReg1[bSector] * 2;

The value of the hReg1 will be used to compute the phase current later. 

Why is the value of the ADC data register multiplied by 2?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
cedric H
ST Employee

Hello @david11 ,

I guess you are using a STM32F4 MCU.

From the release manual (RM0368 Rev 5) , page 221, you can read this :

The converted data value from the injected group of channels is decreased by the userdefined offset written in the ADC_JOFRx registers so the result can be a negative value.
The SEXT bit represents the extended sign value.
For channels in a regular group, no offset is subtracted so only twelve bits are significant

With the following table :

cedricH_0-1699284841017.png

As the FW consider the data left aligned, we must multiply the read value by 2 to align D11 with bit 15.

Hope it helps.

Regards

Cedric

View solution in original post

3 REPLIES 3
Tinnagit
Senior II

I think that No one known what you talk about?

cedric H
ST Employee

Hello @david11 ,

I guess you are using a STM32F4 MCU.

From the release manual (RM0368 Rev 5) , page 221, you can read this :

The converted data value from the injected group of channels is decreased by the userdefined offset written in the ADC_JOFRx registers so the result can be a negative value.
The SEXT bit represents the extended sign value.
For channels in a regular group, no offset is subtracted so only twelve bits are significant

With the following table :

cedricH_0-1699284841017.png

As the FW consider the data left aligned, we must multiply the read value by 2 to align D11 with bit 15.

Hope it helps.

Regards

Cedric

I’ve figured it out a few days after I posted the question. I haven’t checked this forum for a while. Thanks a lot for your useful reply. It helps me make sure that my way of thinking is correct.