Using PIT channel 0 as a PDB trigger input source

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Using PIT channel 0 as a PDB trigger input source

ソリューションへジャンプ
838件の閲覧回数
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)
タグ(2)
0 件の賞賛
1 解決策
530件の閲覧回数
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 返答(返信)
531件の閲覧回数
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 件の賞賛
530件の閲覧回数
nadine
Contributor III

Hi Isaac,

Thanks for the answer. My program is working now.

Best Regards

Nadine,

0 件の賞賛