Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi,

I want to set up the DAC with software triggering but the following code doesn`t work.
What do I have to configure concerning the HWSEL-Register?
When I want to configure the HWSEL Register for the Port 14 it is reset to 0x00000000 automatically by the controller.
Every other Port register (e.g. PORT0.HWSEL) accepts the write and is not reset automatically.


int32_t DAC_init(void)
{
// De-assert a DAC reset
SCU_RESET->PRCLR1 = SCU_RESET_PRCLR1_DACRS_Msk;
//disable gating
SCU_CLK->CGATCLR1 |= SCU_CLK_CGATCLR1_DAC_Msk;

/*---- Config DAC1 ----*/

/* DAC1CFG0 DAC1 Configuration Register 0
* Sets the Mode for DAC1 to Datamode (FIFO)*/
DAC->DAC1CFG0 |= ( (2UL << DAC_DAC1CFG0_MODE_Pos ) & DAC_DAC1CFG0_MODE_Msk);
//

/* DAC1CFG1 DAC1 Configuration Register 1
* Set DAC0 to run*/
//set software trigger
DAC->DAC1CFG1 |= ( ( 2UL << DAC_DAC1CFG1_TRIGMOD_Pos) & DAC_DAC1CFG1_TRIGMOD_Msk );
DAC->DAC1CFG1 |= ( ( 1UL << DAC_DAC1CFG1_ANAEN_Pos) & DAC_DAC1CFG1_ANAEN_Msk );
//use HWO0 output
PORT14->HWSEL = 0x00040000;

return;
}


int32_t DAC1_write(uint32_t data)
{
// only when DAC is running
if(DAC->DAC1CFG0 & DAC_DAC1CFG0_RUN_Msk)
{
DAC->DAC1DATA = data & 0xFFFUL; // mask to 12bit and write into DAC FIFO Buffer
}
//generate trigger
DAC->DAC1CFG1 = ( ( 1UL << DAC_DAC1CFG1_SWTRIG_Pos) & DAC_DAC1CFG1_SWTRIG_Msk );
return;

}



Thanks for any answer.

Benedikt
0 Likes
2 Replies
lock attach
Attachments are accessible only for community members.
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi,

Can you have a look at this example?

This example project uses the DACWG001 App to create different sine waves (different frequencies, offset and amplitude) using the built-in pattern generator of DAC HW. The output can be seen on Pin 14.9 .

Best Regards
Travis
0 Likes
lock attach
Attachments are accessible only for community members.
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Please use this example for XMC4400.
0 Likes