Using PIT channel 0 as a PDB trigger input source

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using PIT channel 0 as a PDB trigger input source

Jump to solution
818 Views
nadine
Contributor III

Hi,

 

Starting from the program pdb_dac_trigger.c available in the KSDK v2.0  driver_examples/pdb directory,

I'm trying to use the PIT Channel 0 as a trigger input source of the PDB instead of a trigger software.

To do so, I have made some unsuccessfully changes in the pdb_dac_trigger.c program. See joined file.

So, any help, or idea is welcome.

 

Best Regards

Nadine,

Original Attachment has been moved to: pdb_dac_trigger.c.zip

Tags (2)
0 Kudos
1 Solution
510 Views
isaacavila
NXP Employee
NXP Employee

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

View solution in original post

0 Kudos
2 Replies
511 Views
isaacavila
NXP Employee
NXP Employee

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

0 Kudos
510 Views
nadine
Contributor III

Hi Isaac,

Thanks for the answer. My program is working now.

Best Regards

Nadine,

0 Kudos