AnsweredAssumed Answered

PIT, PDB to trigger DAC

Question asked by MICHAEL SUTTON on Nov 14, 2011
Latest reply on Aug 7, 2016 by Mark Butcher

I trying to generate a sine wave on the DAC output.  

 

I have the sine wave table stored in the DAC buffer.

 

Everything works, except the DAC updates much faster than I want despite what values I use for PDB0_DACINT0 or PIT_LDVAL0.  It seems to be updating at about 25 MHz.

 

Any suggestions?

 

uint16_t buf[16] ={2047, 2429, 2754, 2970, 3047, 2970, 2754, 2429, 2047, 1664, 1339,1123, 1047, 1123, 1339, 1664}; // Sine wave buffer int i; uint8_t *p; // enable clock to DAC (pg. 289) SIM_SCGC2 |= SIM_SCGC2_DAC0_MASK ;   // enable DAC, use DACREF_2 (wasn't getting output using DACREF_1) DAC0_C0 |= DAC_C0_DACEN_MASK | DAC_C0_DACRFS_MASK; DAC0_C1 |= DAC_C1_DACBFEN_MASK;  p = (uint8_t*)0x400cc000; for(i=0; i < 16; i++) {  *p = (buf[i] & 0xff);  p++;  *p = (buf[i] & 0xf00) >> 8;  p++; }  // Now we need to setup trigger. SIM_SCGC6 |= SIM_SCGC6_PDB_MASK | SIM_SCGC6_PIT_MASK;  // enable clock to PDB and PIT.  // PIT module doc pg 1071  PIT_LDVAL0 = 10000; // don't seem to do what I expect PIT_TCTRL0 |= PIT_TCTRL_TEN_MASK;  // Enable PIT timer PIT_MCR &= ~PIT_MCR_MDIS_MASK; // enable PIT Timer (pg. 1074)  // Now tell PDB to look for PIT0 // PDB Doc on pg. 913  // Select PIT as trigger // PDB0_SC register doc on pg. 920. // Triggers defined on pg. 131   0b0100 is PIT CH 0 PDB0_SC |= PDB_SC_TRGSEL(4) | PDB_SC_PDBEN_MASK;  PDB0_DACINT0 = 0xff; // changing this doesn't change update rate as I would expect PDB0_DACINTC0 |= 1;  // DAC Interval Trigger enable

 

Outcomes