2025-05-23 8:50 PM
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)
those are my IOC settings
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
Solved! Go to Solution.
2025-05-25 6:36 PM
i fond a way to make things workings
2025-05-24 6:12 AM
Your DMA is in normal mode. The tutorial has it in circular mode.
2025-05-24 7:49 AM - edited 2025-05-24 8:11 AM
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
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);
2025-05-24 1:04 PM
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
2025-05-25 6:36 PM
i fond a way to make things workings
2025-05-26 5:10 PM
It helps if you put your solution here so that others in the community may find it.
2025-05-26 10:32 PM - edited 2025-05-26 10:34 PM
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
2025-05-26 10:34 PM
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