Search found 6 matches
- Fri Feb 14, 2025 2:26 pm
- Forum: General discussion
- Topic: STM32G030 how to use DMA to read ADC faster?
- Replies: 7
- Views: 707
Re: STM32G030 how to use DMA to read ADC faster?
I continued working on it, most examples on internet were for F103 so I switched to F103 and eventually made it work, here is code that reads 2000 samples at 400kHz on F103 using DMA. The HAL_ADC_ConvCpltCallback is not triggered so I just put delay(100) there. After pressing "enter" in serial ...
- Thu Feb 13, 2025 6:51 pm
- Forum: General discussion
- Topic: STM32G030 how to use DMA to read ADC faster?
- Replies: 7
- Views: 707
Re: STM32G030 how to use DMA to read ADC faster?
- I added pinMode(*, INPUT_ANALOG) to all 16 adc pins just to be sure and set voltage there to approx 2V
- I added extern C
- still nothing, all zeroes
- if I comment out init_adc_to_use_dma(); and use analogRead(PA0) or any other pin it shows some value, but if I call init_adc_to_use_dma() even ...
- I added extern C
- still nothing, all zeroes
- if I comment out init_adc_to_use_dma(); and use analogRead(PA0) or any other pin it shows some value, but if I call init_adc_to_use_dma() even ...
- Thu Feb 13, 2025 12:28 pm
- Forum: General discussion
- Topic: STM32G030 how to use DMA to read ADC faster?
- Replies: 7
- Views: 707
Re: STM32G030 how to use DMA to read ADC faster?
Here is updated code but still all zeros:
#include "stm32g0xx_hal.h"
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
uint32_t buffer[50];
void init_adc_to_use_dma() {
// Initialize the ADC
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc1.Init ...
#include "stm32g0xx_hal.h"
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
uint32_t buffer[50];
void init_adc_to_use_dma() {
// Initialize the ADC
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc1.Init ...
- Thu Feb 13, 2025 11:27 am
- Forum: General discussion
- Topic: STM32G030 how to use DMA to read ADC faster?
- Replies: 7
- Views: 707
STM32G030 how to use DMA to read ADC faster?
I need to read ADC faster than analogRead can, so I need to use DMA. Here is my code. It doesn't work it prints all zeros:
#include "stm32g0xx_hal.h"
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
uint32_t buffer[50];
void init_adc_to_use_dma() {
// Configure the global features of the ...
#include "stm32g0xx_hal.h"
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
uint32_t buffer[50];
void init_adc_to_use_dma() {
// Configure the global features of the ...
- Thu Nov 09, 2023 11:05 am
- Forum: General discussion
- Topic: What is the fastest way to change pin mode from INPUT_PULLUP to OUTPUT and back
- Replies: 3
- Views: 8754
Re: What is the fastest way to change pin mode from INPUT_PULLUP to OUTPUT and back
Thanks it doubled the reading speed.
- Tue Nov 07, 2023 9:51 am
- Forum: General discussion
- Topic: What is the fastest way to change pin mode from INPUT_PULLUP to OUTPUT and back
- Replies: 3
- Views: 8754
What is the fastest way to change pin mode from INPUT_PULLUP to OUTPUT and back
I need to change pin mode on PB6 and PB7 fast on STM32F103. Originally I was using:
pinMode(PB6, INPUT_PULLUP);
...
pinMode(PB6, OUTPUT);
Then I extracted minimal code from pinMode function:
void pin_function_fast(PinName pin, int function) {
uint32_t mode = function == INPUT ? 0 : 1; // STM ...
pinMode(PB6, INPUT_PULLUP);
...
pinMode(PB6, OUTPUT);
Then I extracted minimal code from pinMode function:
void pin_function_fast(PinName pin, int function) {
uint32_t mode = function == INPUT ? 0 : 1; // STM ...