electroRF Member Oct 18, 2013 #1 Hi I'm using PIC18F4520, with MPLAB IDE, XC8 Compiler. I wanna write code for ISR, at address 0x0008. How do I do that? Thank you.
Hi I'm using PIC18F4520, with MPLAB IDE, XC8 Compiler. I wanna write code for ISR, at address 0x0008. How do I do that? Thank you.
Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Oct 18, 2013 #2 If you write.. C: void interrupt ISR() { // High by default } Or low priority C: void low_priority interrupt ISR() { // Low as required.. } I haven't used / tested this... This is from the manual..
If you write.. C: void interrupt ISR() { // High by default } Or low priority C: void low_priority interrupt ISR() { // Low as required.. } I haven't used / tested this... This is from the manual..
Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Oct 18, 2013 #3 A rewrite.... I hate giving code untested,,,, So I wrote this to test C: #include<xc.h> volatile int x; void interrupt low_priority ISRL() { x = 2; INT1IF = 0; // cancel button 1 press } void interrupt ISRH() { x = 1; INT2IF = 0; // cancel button 2 press } void main(void) { IPEN = 1; // Interrupt prority set,,, ADCON1 = 0xF; // PORTB ADC off INTCON3 = 0x98; // set interrupt priority to INT1 and INT2 INTCON = 0xC0; // GIEH and GIEL set while(1) { } } This DOES work...
A rewrite.... I hate giving code untested,,,, So I wrote this to test C: #include<xc.h> volatile int x; void interrupt low_priority ISRL() { x = 2; INT1IF = 0; // cancel button 1 press } void interrupt ISRH() { x = 1; INT2IF = 0; // cancel button 2 press } void main(void) { IPEN = 1; // Interrupt prority set,,, ADCON1 = 0xF; // PORTB ADC off INTCON3 = 0x98; // set interrupt priority to INT1 and INT2 INTCON = 0xC0; // GIEH and GIEL set while(1) { } } This DOES work...
misterT Well-Known Member Most Helpful Member Oct 19, 2013 #5 electroRF said: Thank you! I'll try it out in my code and will update Click to expand... Have you read the documentation? I know it is over 500 pages, but you do not have to read all of it. The part about interrupts is only 5 pages [189, 194]. https://ww1.microchip.com/downloads/en/DeviceDoc/52053B.pdf Last edited: Oct 19, 2013
electroRF said: Thank you! I'll try it out in my code and will update Click to expand... Have you read the documentation? I know it is over 500 pages, but you do not have to read all of it. The part about interrupts is only 5 pages [189, 194]. https://ww1.microchip.com/downloads/en/DeviceDoc/52053B.pdf