Using PIT channel 0 as a PDB trigger input source

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Using PIT channel 0 as a PDB trigger input source

跳至解决方案
834 次查看
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

标记 (2)
0 项奖励
1 解答
526 次查看
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 项奖励
2 回复数
527 次查看
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 项奖励
526 次查看
nadine
Contributor III

Hi Isaac,

Thanks for the answer. My program is working now.

Best Regards

Nadine,

0 项奖励