Author Topic: Timer Controlled External DAC with STM32F7  (Read 951 times)

0 Members and 1 Guest are viewing this topic.

Offline A.ErsozTopic starter

  • Regular Contributor
  • *
  • Posts: 75
  • Country: us
Timer Controlled External DAC with STM32F7
« on: September 15, 2019, 09:17:17 pm »
Hello,

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

HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_RESET);
DACA_Buf = DAC_A_Write<<12 | HAL_GPIO_TogglePin(DAC_DATA_GPIO_Port, DAC_DATA_Pin)<<4;
HAL_SPI_Transmit(&hspi2,(uint8_t*)&DACA_Buf,16,100);
HAL_GPIO_WritePin(DAC_CS_GPIO_Port, DAC_CS_Pin, GPIO_PIN_SET);

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

Thank you,
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf