I'm trying to adapt the testhal/STM32/STM32F0xx/ADC example on my custom board.
Problem
Normally I expect to read analog value from ADC input and the led blinker thread should toggle the output. However,
1. When I define adcgrpcfg1.circular as TRUE, it perfectly reads Analog Input but fails to execute the thread.
2. If I disable "adcStartConversion()" call, ADC conversion (obviously) doesn't work but the led blinker thread works.
3. If I set adcgrpcfg1.circular as FALSE, replace "adcStartConversion()" with "adcConvert()" and periodically call it, both ADC and blinker thread works, but the blinker thread experiences a lot of jitter.
Configuration and Reproduction Code
Full code can be found here: https://github.com/ceremcem/chibi-examp ... 8d384748bc. PA0 is configured as Digital Output and PA1 is configured as Analog Input, see app/adc/io.h and hw/for-adc-app/STM32F030x4/board.h.
Hardware definitions reside at hw/for-adc-app/ directory.
The ADCConversionGroup struct is as follows (declared in app/adc/main.h):
Code: Select all
static const ADCConversionGroup adcgrpcfg1 = {
circular : TRUE,
num_channels : ADC_CH_NUM,
end_cb : adcReadCallback1,
error_cb : NULL,
cfgr1 : ADC_CFGR1_CONT \
| ADC_CFGR1_RES_12BIT,
// Treshold Register
tr: ADC_TR(0, 0),
smpr : ADC_SMPR_SMP_13P5,
chselr: ADC_CHSELR_CHSEL1
};
Dependencies are: (see dependencies.txt):
Code: Select all
ChibiOS/stable_18.2.x d050860843c6d5c3ef5cf8ab3e5d4cd03060aaf0
GCC 5.3.1
Should I use GPT and periodically call Linear Buffer configuration inside timer callback, or am I doing something wrong?