2024-10-13 07:06 AM - edited 2024-10-13 07:17 AM
Hi, I'm using a Nucleo-H723 board and I need to sample 4 ADC's with variable sampling rate, maximum 1Mbps.
I configure the TMR2 with the time stamp (10ms, 1ms, 10ms, etc...), and TMR3 with the sampling rate that is the input for the ADC trigger.
Values of TMR2 and TMR3 are updated via DMA when TMR2 have an Event (I tested this isolated and is working fine).
Values from ADC are transfer to the buffer via DMA.
I'm having some problems...
The 4 first values of the buffer are always feeded by 0.
And the buffer is only being feeded up to 30463 position when I have a full dma transfer call back (HAL_ADC_ConvCpltCallback). I even let the DMZ in Circular mode, and not disabling the timers, but is all the same data position being populated.
I tested isolated the TMR2 - TMR3 DMA, and they are working fine the change on the Period value.
Someone has any idea of what's happening?
The code is doing nothing else, I'm just trying to implement this transfer Ok before go a head.
I used on USB Device example to work on it.
ADC and TMR3 DMA are set to 16bits, and TMR2 set to 32bits transfer. But seems that 32bits values need to be set with HAL_ADC_Start_DMA and also HAL_DMA_Start_IT.
I think attached are the relevant files. Please let me know if I can provide more information. The HAL_ADC_ConvCpltCallback is in other .c file, the limit to attached here was 3 files.
If I set the buffer to 64k it fills all the buffer normal.
With exception of the first 4 values and the last 12 that are always 0.
I can not transfer more than 16bits address if I'm moving 16bits data? Even configuring on the adc it still the same:
hdma_adc1.Init.PeriphDataAlignment = DMA_MDATAALIGN_WORD;
hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
Thank you!
Solved! Go to Solution.
2024-10-13 10:52 AM
For maximize sample buffer move all data to section for example DTCMRAM and sample buffer then have 320kB area self. 2x50k 16bit is simply 200kB and in config code is reservations for min heap and stack , now all this aranged into 320k area.
2024-10-13 07:24 AM
I confirmed that up to 65535 it work nice, besides the first 4 and last 12 zeros.
There is a way to workaround this?
I need a big buffer to have all the test data.
2024-10-13 08:34 AM
Unfortunately this is the true, max 16 bit.
2024-10-13 10:24 AM
Yes max count in DMA is 16bit x size of data. But why you require big buffer? Must be allocated in DMA accesible memory. Use normal not circular and in complete start new with next buffer page...
Primary learn use right syntax
HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET_LINEARITY, ADC_SINGLE_ENDED);
HAL_ADC_Start_DMA(&hadc1, (uint32_t)&adc_buffer, (uint32_t)ADC_BUF_SIZE);
normal check for return values, wait for end calib , &adc_buffer is ugly and if convert then to (uint32_t *)
HAL_ADC_Start_DMA(&hadc1, (uint32_t *)adc_buffer, ADC_BUF_SIZE);
or
HAL_ADC_Start_DMA(&hadc1, &adc_buffer[0], ADC_BUF_SIZE);
2024-10-13 10:40 AM
The reason is because I wish to storage the ADC value during a certain period of time that the test will happen.
I'm nothing close to software expert, I work with hardware, so I'm trying to find a way to do the test.
Thank you for the syntax inputs.
You are right, I did not think on this possibility, to start a new buffer in other memory position when completed the first.
I will split my 4 channels in ADC1 and ADC2, this will be already enough, and I will be able to run on different sampling rate.
I just wish I have more memory to be able to storage more time with high sampling rate.
I have this usage bellow, but if I increase my buffer 1k more (I'm using 2x 50k) I receive this error: overlaps section ._user_heap_stack VMA
Is it possible to change the memory map to increase the buffer size?
2024-10-13 10:52 AM
For maximize sample buffer move all data to section for example DTCMRAM and sample buffer then have 320kB area self. 2x50k 16bit is simply 200kB and in config code is reservations for min heap and stack , now all this aranged into 320k area.
2024-10-13 11:07 AM
This also solved the issue of 0 in the beginning and end of the buffer.
Thank you for your help.