cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to run the ADC with DMA on STM32H755ZI-Q

William133467
Associate III

Hi,

I a using a NUCLEO-H755ZI-Q on STMCubeide 1.18.0

i am trying to use the Timer 1 to capture on the rising edge using the analog to digital converter 
those are my signals the lase one (pink is my signal that i want to capture at this frequency)

William133467_1-1748057361673.png

those are my IOC settings

William133467_2-1748057954527.png

William133467_3-1748058016884.png

William133467_4-1748058563086.png

 

on the input of the ADC I have an analog signal Syncronised on timer one for capture

i try using this Tutorial and only obtain those results:


Sample 0: 1184
Sample 1: 1160
Sample 2: 1187
Sample 3: 1116
Sample 4: 1170
Sample 5: 1146
Sample 6: 1176
Sample 7: 1188
Sample 8: 1168
Sample 9: 1187
(i an not sure that i am 

my code for this is 

#define CCDBuffer 6000
volatile uint16_t CCDPixelBuffer[CCDBuffer];
uint16_t ProcessingBuffer[CCDBuffer];


[...]

HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_1); //sh

HAL_ADC_Start_DMA(&hadc1, (uint32_t*)CCDPixelBuffer, CCDBuffer);

[...]

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {
    // Copier les données du buffer ADC dans le buffer de traitement
    for (int i = 0; i < CCDBuffer; i++) {
        ProcessingBuffer[i] = CCDPixelBuffer[i];
//tempory code to make the adc work and show data
}

}

 so i get data once and nothig after i had the impression the i was supose to capture data when the timer one is active but seem like it only work one time


my plan is to gather data in a buffer to later make mathematical operation but cant get it to work propelly all the time the timer one is active



Thanks for any help, I am new to STM32 sorry for any spelling error english isn't my first language

1 ACCEPTED SOLUTION

Accepted Solutions
William133467
Associate III

i fond a way to make things workings

View solution in original post

7 REPLIES 7
TDK
Super User

Your DMA is in normal mode. The tutorial has it in circular mode.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you so mutch for you repply it is really appreciated 

i  have change the mode to circular mode but now i have no data output sample its not running enven once before stopping did i miss something else thak you for any help i relly appreciate it

 

William133467_0-1748097678007.png

EDIT i change the priority to HIGH and the setting for my code is:

void SystemClock_Config(void);
void PeriphCommonClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_TIM2_Init(void);
static void MX_TIM3_Init(void);
static void MX_TIM4_Init(void);
static void MX_TIM1_Init(void);
static void MX_ADC1_Init(void);
William133467
Associate III

If anyone know, ST emplye or orher i would be gratefull for any informations i think i have a problem in the oic file i might have setup some parameter the wrong way 

thanks in advance for any help i cant find a solution 

William133467
Associate III

i fond a way to make things workings

It helps if you put your solution here so that others in the community may find it.

If you feel a post has answered your question, please click "Accept as Solution".

William133467_0-1748323595937.pngWilliam133467_1-1748323622235.png

 

in big you need to remap to ramd2 

main code:


void StartAcquisition(void);
void StopAcquisition(void);

__attribute ((section(".adcarray"))) uint16_t ADC_VAL[3694];


void StartAcquisition(void) {
	BSP_LED_On(LED_YELLOW);

    __HAL_TIM_SET_COUNTER(&htim2, 95);
    __HAL_TIM_SET_COUNTER(&htim4, 75);

    HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1); // fm
    HAL_TIM_Base_Start(&htim1);               // adc trigger
    HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // icg
    HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_1); // sh

    HAL_ADC_Start_DMA(&hadc1, (uint32_t *)ADC_VAL, 3694);
}

void StopAcquisition(void) {


    HAL_ADC_Stop_DMA(&hadc1);

    HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
    HAL_TIM_Base_Stop(&htim1);
    HAL_TIM_PWM_Stop(&htim2, TIM_CHANNEL_1);
    HAL_TIM_PWM_Stop(&htim4, TIM_CHANNEL_1);
    BSP_LED_Off(LED_YELLOW);
}

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {
    // Copier les données du buffer ADC dans le buffer de traitement
    //for (int i = 0; i < CCDBuffer; i++) {
        //ProcessingBuffer[i] = CCDPixelBuffer[i];

	//ADC_VAL = HAL_ADC_GetValue(hadc);

	//printf("ADC value (DMA): %u\r\n", ADC_VAL[0]);
	SCB_InvalidateDCache_by_Addr((uint32_t *)0X30000000, 7388);
	StopAcquisition();
    acquisitionDone = true;
    acquisitionInProgress = false;



flash.ld :

	.mysection (NOLOAD):
	{
		. = ABSOLUTE(0x30000000);
		*(.adcarray)
	} >RAM_D2

 

sorry if i am missing some step but i am on my finals to finish my projet and got only 2 days left i made everything work from controllersTech on youtube u search ADC and the playlist is there