I'm trying to make output on pin A4 with DAC driver and it doesn't work. My board is Nucleo 64 (STM32f446RE) and here is my code:
Code: Select all
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
/*
* Starting DAC1 driver, setting up the output pin as analog as suggested
* by the Reference Manual.
*/
static const DACConfig dac1cfg = {
.init = 4047U,
.datamode = DAC_DHRM_12BIT_RIGHT
};
palSetPadMode(GPIOA, 4, PAL_MODE_INPUT_ANALOG );
dacStart(&DACD1, &dac1cfg);
dacPutChannelX(&DACD1, 0, 4000);
/*
* Normal main() thread activity, if the button is pressed then the DAC
* transfer is stopped.
*/
while (true) {
chThdSleepMilliseconds(500);
}
return 0;
}
what I'm doing wrong?