Clearing PIT Timer Interrupt Flag causing exception

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

Clearing PIT Timer Interrupt Flag causing exception

ソリューションへジャンプ
1,443件の閲覧回数
guitardenver
Contributor IV

I am using the PIT for a delay function. It sets up the timer based on the delay passed in and polls for the interrupt flag, stops the timer and exits. This has been working great. But then I set up a pin interrupt triggering on both rising and falling edges and then I call my delay function inside that interrupt. And It seems like if I write anything to the PIT registers it causes an exception. Goes to the defaultISR.

 

void usDelay(uint32_t us) {

  uint8_t i = 0;

  uint32_t count = (US_FREQ_BUS*us);

 

 

 

 

  //PIT_HAL_ClearIntFlag(g_pitBaseAddr[US_DELAY_INSTANCE], US_DELAY_CHAN);

  PIT_TFLG0 = 0x01;

 

 

  if(count > US_DELAY_TRIM) {

  PIT_DRV_SetTimerPeriodByCount(US_DELAY_INSTANCE, US_DELAY_CHAN, count - US_DELAY_TRIM);

  count = count - US_DELAY_TRIM;

  } else {

 

 

  PIT_DRV_SetTimerPeriodByCount(US_DELAY_INSTANCE, US_DELAY_CHAN, count);

  }

 

 

  PIT_HAL_StartTimer(g_pitBaseAddr[US_DELAY_INSTANCE], US_DELAY_CHAN);

 

 

  while(!PIT_HAL_IsIntPending(g_pitBaseAddr[US_DELAY_INSTANCE], US_DELAY_CHAN));

 

 

  PIT_HAL_StopTimer(g_pitBaseAddr[US_DELAY_INSTANCE], US_DELAY_CHAN);

 

 

}

 

 

In the debugger, the line   PIT_TFLG0 = 0x01; executes and then the next operation (does not matter what it is) causes the exception. But this only happens when I call this delay function from an interrupt.

ラベル(1)
0 件の賞賛
返信
1 解決策
1,125件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Matt Lang:

What MCU target are you using? And what IDE (KDS, IAR, Keil)?

The problem sounds like if the PIT clock gate was not enabled, but if it fails only when calling your delay function from the ISR then that should not be the cause.

If possible please share your project in a zip file to take a look at it.

Regards!

Jorge Gonzalez

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
1,126件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Matt Lang:

What MCU target are you using? And what IDE (KDS, IAR, Keil)?

The problem sounds like if the PIT clock gate was not enabled, but if it fails only when calling your delay function from the ISR then that should not be the cause.

If possible please share your project in a zip file to take a look at it.

Regards!

Jorge Gonzalez

0 件の賞賛
返信