Jump to content

Favere Mario

  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Favere Mario

  • Rank
  1. Hi I approve the solution IanM did bring, the final (and for me 'clean') version is : #include <system.h> void interrupt(void) { intcon&=0b11111110; // reset IF porta++; } void main() { char a; trisb=255; trisa=0; porta=0; a=portb; // clear initial mismatch intcon=0b11001000; // enable IR's while (1); } This is working just fine :-) Let's hope the ECIO will do the same IRL ;-) - but that's for tomorrow. I'll give news !
  2. This is neat indeed !! Does there exist a similar way to use more than one LED-bar ? tx !
  3. Thought you had found a simulator bug, but looks like this is NOT the case Extract from 18F4455 data sheet: You have to read the port again: void interrupt(void) { intcon&=0b11111110; // clear PortB IF porta++; char a = portb; // read port to stop repeated interrupts for same port value } Regards Dave Hi Dave, Thank you for you're reply ! The datasheets says also : The user, in the Interrupt Service Routine, can clear the interrupt in the following manner: a) Any read or write of PORTB (except with the MOVFF (ANY), PORTB instruction). This will end the mismatch condition. Clear flag bit, RBIF. I use (generaly proposed to clear an interrupt) the -way. To make it Work in BoostC the programmer should apply AND a) AND in order not to return to the ISR when nothing happens (only clearing the IF works in other IDE's e.g. Wiz-C). Tomorrow I'll try the -rb 0x800 directive and download the HEX into an ECIO. I let you know :-)
  4. Hi, I'm testing the free version of BoostC to teach my students in september som basics. I need to show how interrupts work and have writen a verry small sample program : // Target = 18F4455 #include <system.h> void interrupt(void) { intcon&=0b11111110; // clear PortB IF porta++; } void main() { trisb=255; // set port b to input trisa=0; // set port a to output porta=0; // clear port a intcon=0b11001000; // GIE on , PEIE on, RBIE on while (1); } The interrupt is triggered even without PORTB changes, and the debugger can't get out of the ISR (rejumps directly into a new interrupt request). Altough this little program works.... If I use the linker directive -rb 0x800 (with the ECIO we need a code offset du to bootloader at 0x800) the program resets when the interrupt is called (I assume the interrupt vector is not changed). A little hint for the BoostC developpers : it should be nice to use more than one instance of a plugin, e.g. be able to use 4 led-bars at the same time. Any hints are welcome ... Mario elac@online.be
  • Create New...