cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in StdPeriphLib Driver

mismee
Associate II
Posted on December 25, 2009 at 02:36

Bug in StdPeriphLib Driver

3 REPLIES 3
mismee
Associate II
Posted on May 17, 2011 at 13:35

Hi!

I`ve found bug in StdPeriph library version 3.1.2. Function ADC_InjectedChannelConfig is incorrect configuring ADC_JSQR register.

In stm32f10x_adc.c line 974 must

tmpreg2 = JSQR_JSQ_Set << (5 * (uint8_t)((Rank + 1) - (tmpreg3 + 1)));

instead

tmpreg2 = JSQR_JSQ_Set << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1)));

line 978:

tmpreg2 = (uint32_t)ADC_Channel << (5 * (uint8_t)((Rank + 1) - (tmpreg3 + 1)));

instead

tmpreg2 = (uint32_t)ADC_Channel << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1)));

This is done for proper config ADC_JSQR.

armmcu
Associate II
Posted on May 17, 2011 at 13:35

Hi mismee,

I've quickly checked the case and the code as it's now in the library driver v3.1.2, is correct :o :o .

I guess there is an important note in RM008 that you should consider..

''Note:

Unlike a regular conversion sequence, if JL[1:0] length is less than four, the channels

are converted in a sequence starting from (4-JL). Example: ADC_JSQR[21:0] = 10 00011 00011 00111 00010 means that a scan conversion will convert the following channel sequence: 7, 3, 3. (not 2, 7, 3)''

Cheers,.

[ This message was edited by: armmcu.engineer on 24-12-2009 18:28 ]

[ This message was edited by: armmcu.engineer on 24-12-2009 18:31 ]

mismee
Associate II
Posted on May 17, 2011 at 13:35

Thanks armmcu.engineer.

I has not seen this note.

Thank you