EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: A.Ersoz on September 15, 2019, 09:17:17 pm

Title: Timer Controlled External DAC with STM32F7
Post by: A.Ersoz on September 15, 2019, 09:17:17 pm

I have an external 8 bit DAC (DAC082S085) on my custom designed board with stm32f767. I can command to DAC for generating a step function signal. But now I want to generate a square wave signal as an output of the DAC. The square wave of signal will generate from a timer for setting a period/frequency of the signal.

For this purpose, I set TIMER3 in Cube MX with internal clock settings. I adjusted its prescaler 108-1 and counter period as 100-1 for getting 100us square wave signal. I write the code like this,

Code: [Select]
uint8_t DAC_A_Write = 0x1; // DAC's A output is selected 0 0 0 1
uint8_t DAC_B_Write = 0x5; // DAC's B output is selected 0 1 0 1
uint16_t DACA_Buf; // Output A of the DAC
uint16_t DACB_Buf; // Output B of the DAC

DACA_Buf = DAC_A_Write<<12 | HAL_GPIO_TogglePin(DAC_DATA_GPIO_Port, DAC_DATA_Pin)<<4;

How can I solve the problem? I also want to control the amplitude of the signal.

Thank you,