cancel
Showing results for 
Search instead for 
Did you mean: 

13 channels of ADC + DMA = data in the wrong order

djackson
Associate II
Posted on June 04, 2014 at 23:50

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
7 REPLIES 7
Posted on June 05, 2014 at 00:30

static const rank_channel_tuple_t rank_channel_table[] = { /* Channel assignment */
{ IVSENSE_CH_A, 0 }, PA0 123_0
{ IVSENSE_CH_B, 4 }, PA4 12_4
{ IVSENSE_CH_C, 14 }, PB0 12_8
{ IVSENSE_CH_D, 15 }, PB1 12_9
{ IVSENSE_CH_E, 8 }, PC0 123_10
{ IVSENSE_CH_F, 9 }, PC1 123_11
{ IVSENSE_CH_G, 10 }, PC2 123_12
{ IVSENSE_CH_H, 11 }, PC3 123_13
{ IVSENSE_CH_I, 12 }, PC4 12_14
{ IVSENSE_CH_J, 13 }, PC5 12_15
{ IVSENSE_CORETEMP, 16 },
{ IVSENSE_VREFINT, 17 },
{ IVSENSE_VBAT, 18 }
};

Yikes! Either that table is bad, or the comments related to the pin assignments are wrong
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
djackson
Associate II
Posted on June 05, 2014 at 03:09

Or I wrote down the wrong part (I was working with an F407 earlier today as well).   The mapping above is really on the F405RGT6, 64-pin.

Posted on June 05, 2014 at 04:18

I'm not sure the bond out of the pins from the die makes any difference, I think you need to double check the A-J designators and the associated pins on the device in the schematic.

My annotations to the table relate the the GPIO assignments described in the code.

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; /* Configure GPIOA.0 as analog input (CH A) */
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; /* Configure GPIOA.4 as analog input (CH B) */
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; /* Configure GPIOB.0 as analog input (CH C) */
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; /* Configure GPIOB.1 as analog input (CH D) */
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; /* Configure GPIOC.0 as analog input (CH E) */
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; /* Configure GPIOC.1 as analog input (CH F) */
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; /* Configure GPIOC.2 as analog input (CH G) */
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; /* Configure GPIOC.3 as analog input (CH H) */
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; /* Configure GPIOC.4 as analog input (CH I) */
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; /* Configure GPIOC.5 as analog input (CH J) */
GPIO_Init(GPIOC, &GPIO_InitStructure);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
djackson
Associate II
Posted on June 05, 2014 at 05:19

A copy/paste/remove-the-proprietary-names error.  I've relabeled the GPIO comments to match the order that the code is really in. 

When I apply voltages to each of my inputs, I'm getting the correct changes but the data in the output array is in the wrong spot when I have 13 inputs.

Expected for 13 inputs and actual with 12 inputs based on ADC_RegularChannelConfig():

   Ch_A, Ch_B, Ch_C...

Actual with 13 inputs:

  Ch_J, CoreTemp, Vrefint, Vbat, Ch_A, Ch_B, ....

Posted on June 05, 2014 at 18:38

Understood.

Not sure why it would foul the order up, I'd perhaps use half-words, but need to stand some code up to see if I can independently duplicate.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
djackson
Associate II
Posted on June 06, 2014 at 02:58

I tried switching both the Memory and Peripheral DMA flags to to half-words and got the same results.

djackson
Associate II
Posted on July 24, 2014 at 22:46

I didn't want to leave this thread hanging.: I finally got back to this with a newer build of code -- the ADC section had been turned off since it wasn't required for what we were using.  Everything is working now.  Interestingly, going back to the version that had the offsets in the output still shows the data incorrectly.  Nothing stands out as being different.  

This is concerning and I'll have to look further into it.