Review on critical section
Hello guys. My recent code works good, but sometimes it behaves uncertainly. I need your suggestions regarding the critical section of the code that I have implemented, is further need any modifications.
I am using pic24f mcu.
void __attribute__((interrupt,no_auto_psv)) _IC1Interrupt(void)
cap1 = IC1BUF;
cap2 = IC1BUF;
IFS0bits.IC1IF = 0;
In main code,
IEC0bits.IC1IE = 0; //disbale the interrupt
counts = cap2-cap1;
IEC0bits.IC1IE = 1; // interrupt enable again
Another interrupt is accessing the variable "value" that is being modified in the main loop, but here I didn't disable the interrupt.
void __attribute__((interrupt,no_auto_psv)) _U1RXInterrupt(void)
IFS0bits.U1TXIF = 0;