I was wondering how to create an array on STM32cubeIDE. I like to fill this array with values from an independent LDR.
Below is the set-up code for the ADC:
/*User Begin PV*/
uint16_t value_DAC = 0;uint16_t value_ADC =0;uint32_t state_DAC = 0;
/*User Begin 2*/
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED); // Calibrate ADC
HAL_ADC_Start_DMA(&hadc1, (uint32_t *) &value_ADC, 1); // Start ADC with DMA
HAL_DAC_Start(&hdac1, DAC_CHANNEL_2); // Start the DAC
Any help would be much appreciated.
I haven't tried anything yet because I really don't know where to start.
your question is a bit unclear. if you could already read the adc value, the only thing to do on top is to make a simple c array like
int value_ADC[20];
and then read and store the adc value in it periodically with your desired interval. to do so you can either use blocking method with a loop if the only thing you wanna do is to read adc like this:or non-blocking if you have parallel tasks, with "timer interrupts" that you can learn more about by searching the term. if the speed of timer was too high you can use a counter to read adc value every 100th interrupt for example and also reset the counter.