8 years ago.

DAC definitions on STM32F103

I'm trying to use the DAC on the ATM32F103, but it seems the declaration files are not included.

I have written the code below to initialize it:

DAC INIT

// Initialize the DAC

 DAC->CR |= ((7ul << 19));                                    // Software trigger sets DAC CH2
 DAC->CR &= ~ ((1ul << 18));                              // Trigger disabled. write to DAC_DHRx Register
 DAC->CR &= ~ ((1ul << 17));                              // Enable DAC Output buffer
 DAC->CR |= ((1ul << 16));                                    // Enable DAC Channel 2*/
 
 DAC->CR |= ((7ul << 3));                                       // Software trigger sets DAC CH1
 DAC->CR &= ~ ((1ul << 2));                                // Trigger disabled. write to DAC_DHRx Register
 DAC->CR &= ~ ((1ul << 1));                                // Enable DAC Output buffer
 DAC->CR |= ((1ul << 0));                                      // Enable DAC Channel 1

The code doesn't compile, and the following error is shown: Error: Identifier "DAC" is undefined in "main.cpp", Line: 145, Col: 3

Any ideas?

Be the first to answer this question.