I have a problem for converting a simple digital value with the DAC driver :
- In async mode, callbacks (error and success) are never called.
- In sync mode, the program blocks at dacConvert( .. ) more precisely l.304 of dac.c in osalThreadSuspendS ( .. )
Here is a minimal code to reproduce the issue (sync mode) :
Code: Select all
#include "ch.h"
#include "hal.h"
static const dacsample_t dac_buffer[1] = {2047};
static const DACConfig dac1cfg1 = {
init: 2047U,
datamode: DAC_DHRM_12BIT_RIGHT
};
static const DACConversionGroup dacgrpcfg1 = {
num_channels: 2U,
end_cb: NULL,
error_cb: NULL,
};
int main(void) {
halInit();
chSysInit();
palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG);
dacStart(&DACD1, &dac1cfg1);
msg_t t1 = dacConvert(&DACD1, &dacgrpcfg1, dac_buffer, 1);
while (true) {
chThdSleepMilliseconds(500);
}
return 0;
}
My mcuconf.h:
Code: Select all
#define STM32_DAC_DUAL_MODE FALSE
#define STM32_DAC_USE_DAC1_CH1 TRUE
#define STM32_DAC_USE_DAC1_CH2 TRUE
#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
I was inspired by the DAC demo for STM32F4xx ( in master/testhal/STM32/STM32F4xx/DAC/ )
Thanks for any help
Geoffroy