2022-02-16 04:12 PM
I am reading 4 values, AN0, AN1, Temp, and the Reference. (But reference may go away.)
I am over sampling 16x. and eventually will be starting a sequence every 100 us.
I wanted two buffers, so I could work on one, while filling the other.
I thought a circular buffer would work. I make it 8 16-bit words and have a half-full buffer interrupt go when the first 4 words are done, and have the buffer-full interrupt go when the second 4 words are finished.
It does work that way.
The only issue is that it starts on second memory location not the first.
When I prefill the array with zeros, the array looks like this after the first transfer.
<invalid data> <data 0> <data 1> <data 2> <data 3> 0 0 0
And after the second DMA transfer it looks like this
<data 7> <data 0> <data 1> <data 2> <data 3> <data 4> <data 5> <data 6>
And after the third DMA Transfer it looks like this:
<data 7> <data 8> <data 9> <data 10> <data 11> <data 4> <data 5> <data 6>
Is there a way to fix this so the first data transfer starts on the first memory location? Or what am I doing wrong?
This is a STM32G031
And I am using HAL_ADC_Start_DMA() to start the DMA.
Here is what the ADC registers look like after the first transfer.
ADC_ISR: 200A
ADC_IER: 0010
ADC_CR: 10000001
ADC_CFGR1: 00000003
ADC_CFGR2: 2000000D
ADC_SMPR: 00000336
ADC_AWD1TR: 0FFF0000
ADC_AWD2TR: 0FFF0000
ADC_AWD3TR: 0FFF0000
ADC_CHSELR: 00003003
ADC_DR: 00005DAF
ADC_AWD2CR: 00000000
ADC_AWD3CR: 00000000
ADC_CALFACT: 00000035
ADC_COMMON_CCR: 00C00000
I think I can make it work the way it is, but it would be easier if it were aligned right.
2022-02-18 07:01 AM
Documentation is the worst part of the STM32 parts. I find mistakes all the time. They also make it difficult to find the documentation, It should be very easy.
Even the datasheets are hard to find from the website. You find a family, then it gives you a list of say 7 datasheets with a number that has no correspondence to the part number. So you have to download and open the datasheet to see which part in the family the datasheet you downloaded is for.
Maybe it is a French or Italian thing... :grinning_face:
2022-02-18 07:08 AM
Yes you are right on that. Debuggers have a lot of problems with peripherals and interrupts. It does not matter which chip you are working with. That is why I get fast writes out to a serial port as the first thing in any processor I bring up. My Linux computer can read 2,000,000 baud with a FDTI 3.3V logic serial to USB (TTL-232R-3V3-WE). With DMA transfers it helps a lot in debugging real time.
2022-03-18 05:03 PM
ST's web page, forum and basically everything related to software is terrible, but not in a way you describe.
The images of subseries and part numbers are clickable. Navigate to the page of specific part and the Documentation tab there will show the documents only relevant to that part. Or search the part number with Google and it will give the direct link instantly: