Hello Nadine,
Some quick points:
- You were having hard fault interrupts when trying to write to DAC registers before initializing DAC module. You started the PIT timer, then, once it has an overflow, it triggers the PDB, on the PDB interrupt, you tried to write to DAC registers but at that time, DAC wasn't initialized and then a hard fault occurred. To avoid it, just start the PIT module just after PIT, PDB and DAC have been initialized:
/* FIfo loading */
for (DACIndex = 0U; DACIndex < DAC_USED_BUFFER_SIZE; DACIndex++)
{
DAC_BASE->DAT[DACIndex].DATL = datl[sinusIndex]; /* Low 8-bit. */
DAC_BASE->DAT[DACIndex].DATH = dath[sinusIndex]; /* High 4-bit. */
sinusIndex++;
}
if (sinusIndex >= SINUS_SIZE)
sinusIndex = 0;
DACIndex = 0;
PIT_StartTimer(PIT, kPIT_Chnl_0);
- PIT trigger is used to start PDB counting. If you select to use continuous mode (on PDB configuration), then once PIT has triggered PDB module, PDB will generate pulses according to its MOD and CNT registers (It will not use PIT anymore, due PDB has already been triggered and it is configured as continuous mode), on the other hand, if you want to be synchronized by PIT, you will have to disable continuous mode, so this way, PIT could start PDB once it has finish counting.
I hope this can help you!
Best Regards,
Isaac