0
\$\begingroup\$

I have a Microchip PIC161776 running at 32 MHz. Interrupt Code has been generated with MCC, with the preemptive option set. typically, about once every hour the interrupt routine gets called with no apparent set flag.

The MCC generates code like:

ISR(){

if (IF1) { } else if (IF2) { } else if ... { } else { THIS PART OF CODE GETS CALLED! } }

Anybody know of issues with this particular microcontroller ? As far as I know (and checked with debugger), no unkown interrupt sources are enabled.

\$\endgroup\$
  • \$\begingroup\$ sounds like a glitch \$\endgroup\$ – Sunnyskyguy EE75 Sep 5 '17 at 19:34
  • \$\begingroup\$ possibly, but what would cause it ? in theory the interrupt controller should not call the interrupt routine unless there is a flag set somewhere, and that flag would not reset by itself unless some code is executed (like clearing the flag or read a particular register). \$\endgroup\$ – Brian Jordan Sep 5 '17 at 19:41
  • \$\begingroup\$ look up pic16 phantom interrupt \$\endgroup\$ – Sunnyskyguy EE75 Sep 6 '17 at 2:43
0
\$\begingroup\$

Are you using PIC's Interrupt-On-Change feature? There is a known bug in 18F HW. I'm not sure if it affects 16 series.

http://www.microchip.com/forums/m294169.aspx

http://www.xargs.com/pic/portb-change-bug.html

So, we must read PORTB first, to clear the difference which got us here in the first place, and then clear RBIF, then read PORTB again (without clearing RBIF) to insure that any change on the pins between Q1 and Q3 that instruction is detected.

\$\endgroup\$
  • \$\begingroup\$ Thank you for your reply. No, I don't use any Interrupt-on-Change, but thanks to you I now know there are some potential glitches there. \$\endgroup\$ – Brian Jordan Sep 5 '17 at 20:30
  • \$\begingroup\$ Yes, HW bugs are there and often are left unfixed due to cost. Always check the errata when you un into weird things. I found a bug in one PIC related to USB and their expert engineer could not fix it and said it seemed like a HW bug. He did give me a SW workaround for it. So yes it does happen. \$\endgroup\$ – Vince Patron Sep 5 '17 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.