Hi everyone,
Though I've been consulting this forum for a while, this is my absolute first thread, so I apologize in advance if I haven't included some critical information needed to troubleshoot my issue. I've looked around here (and other online resources) for hours but I haven't seen anything that really describes my issue, so here goes:
Device: dsPIC30F4013, MPLAB X IDE v5.40, Compiler: XC 16, Programming device: PICkit3. OS: Windows 10
Functionality description: The program's main loop counts up the number of times a button is pressed (pin RFO[30]) and prints the current count to an LCD screen (this part works fine). I need to write 3 interrupt routines which will read 3 NPN inductive sensors, each of which shall print a unique alarm message to the screen. Only after the sensors are reset (they're "seeing" metal again) AND a Reset button programmed at pin RB1[3] is pushed (as an acknowledge button), should the program return to the main loop where it can count again.
The NPN sensors I'm using work at 12VDC, and I'm using 3 PC817 optocouplers to isolate this high voltage from the 5VDC I'm supplying to the dsPIC30F4013 (and the signals the optocouplers send). I have checked that these devices work properly and that they're only sending a signal when they're supposed to.
I programmed the 1st interrupt at pin INT0/RA11[18] and this worked as expected. I then copied most of this code (modifying the appropriate registers) and am now also using INT1/RD8 [23] as input for the 2nd interrupt routine. The program compiles with no errors, however, when I test this on my PCB, only one of the interrupts works. When I comment INT0, INT1 works as expected, and vice versa. They cannot work simultaneously. To clarify, I don't mean that I can't use nested interrupts (this isn't what I'm trying to do), but that when I energize the dsPIC, only 1 interrupt works at all. Note that the interrupt that works is always the same one (whichever was the most recent one to NOT be commented before I uncommented both interrupts).
For the sake of brevity, I've included my code in a .txt file for your consideration.
Thank you very much for any help you might be able to provide.
Best regards,
Rob