Jorge,
In response to your original question about using the DAC buffer, here is some code I was able to use to implement a 2 element circular buffer using the PIT as hardware trigger source. Everything is taken care of in the initialization. An application of this would be to generate a square wave with an amplitude less than VDD without having to use the core.
As is, the code will generate a square wave on PTE30 of the freedom board, with period 200us (assuming 24MHz bus).
void init_DAC()
{
/* Enable device clock gate */
SIM_SCGC6 |= SIM_SCGC6_DAC0_MASK;
/* DACRFS = 0, DAC selects DACREF_1 VREFH
DACRFS = 1, DAC selects DACREF_2 VDDA */
DAC0_C0 |= DAC_C0_DACRFS_MASK;
/* PORTE_PCR30: ISF=0,MUX=0 */
PORTE_PCR30 &= (uint32_t)~(uint32_t)((PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x07)));
/* Enable low-power mode */
DAC0_C0 |= DAC_C0_LPEN_MASK;
/*
DATA[7:0] corresponds to DACx_DATnL
DATA[11:8] corresponds to DACx_DATnH */
DAC0_DAT0L = 0x00;
DAC0_DAT0H |= 0x0;
DAC0_DAT1L = 0xFF;
DAC0_DAT1H |= 0xF;
/* Hardward trigger sel */
DAC0_C0 &= ~DAC_C0_DACTRGSEL_MASK;
/* Normal buffer mode */
DAC0_C1 &= ~DAC_C1_DACBFMD_MASK;
/* Enables buffer read ptr */
DAC0_C1 |= DAC_C1_DACBFEN_MASK;
/* Selects the upper limit of the DAC buffer */
DAC0_C2 |= DAC_C2_DACBFUP_MASK;
/* Lastly, turn on the DAC */
DAC0_C0 |= DAC_C0_DACEN_MASK;
}
void init_PIT()
{
//Enable periodic interrupt timer
SIM_SCGC6 |= SIM_SCGC6_PIT_MASK;
//MDIS in PIT_MCR needs to be = 0
PIT_MCR = 0x00;
//LDVAL trigger = (period / clock period) -1 */
//Set a timer start value (200us)
PIT_LDVAL0 |= 0x000012BF;
//Starts timer
PIT_TCTRL0 |= PIT_TCTRL_TEN_MASK;
}