• AVR Freaks

Hot!Problem disable interrupt from IC in interrupt code

Author
dobrosoft
Junior Member
  • Total Posts : 108
  • Reward points : 0
  • Joined: 2019/05/20 04:44:55
  • Location: 0
  • Status: offline
2020/07/20 07:03:48 (permalink)
0

Problem disable interrupt from IC in interrupt code

Hello. 
 
I'm using PIC32MZ2048EFH100, Harmony 2.06
 
One IC pin i use for detect PWM input signal. It works well, signal has cca 200Hz of period.
 
But I find problem with source of signal, where has been high frequency noise - more than 50kHz, and it causes problem of lot of interrupt running. 
 
Idea is to disable IC interrupt before clearing interrupt flag and in 1ms new timer enable IC interrupt again:
 
system_interrupt.c : example of code, which works well, but high frequency noise hang up processor
 
void __ISR(_INPUT_CAPTURE_1_VECTOR, ipl5AUTO) _IntHandlerDrvICInstance0(void)
{
...
//working code of detect pwm input period and duty cycle
...
PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_INPUT_CAPTURE_1);
}
 
system_interrupt.c : code the same, but in finishing - disable interrupt
 
void __ISR(_INPUT_CAPTURE_1_VECTOR, ipl5AUTO) _IntHandlerDrvICInstance0(void)
{
...
//working code of detect pwm input period and duty cycle
...
PWM_IC_FLAG = SYS_INT_SourceDisable(INT_SOURCE_INPUT_CAPTURE_1);
PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_INPUT_CAPTURE_1);
}
 
And then in timer routine with alarmCount 1ms added this:
if (alarmCount){
   if (PWM_IC_FLAG){
     SYS_INT_SourceEnable(INT_SOURCE_INPUT_CAPTURE_1);
   }
}
 
And here is problem, when I add PWM_IC_FLAG = SYS_INT_SourceDisable(INT_SOURCE_INPUT_CAPTURE_1); to end of IC interrupt routine IC capture interrupt disable, processor hangup, and I don't know why. I try to debug what causes the problem. Timer routine in independent timer interrupt will not execute.
#1
Jump to:
© 2020 APG vNext Commercial Version 4.5