Hi All,
I have the following problem with the PIC18F4550.
The EUSART is initialized as follows:
movlw b'11111111'
movwf TRISC,ACCESS
movlw low(d'1249')
movwf SPBRG,ACCESS
movlw high(d'1249')
movwf SPBRGH,ACCESS
movlw b'00000100'
movwf TXSTA,ACCESS
movlw b'10000000'
movwf RCSTA,ACCESS
movlw b'00001000'
movwf BAUDCON,ACCESS
bsf PIE1,RCIE,ACCESS
bsf IPR1,RCIP,ACCESS
bsf RCSTA,CREN,ACCESS
Then the interrupts are enabled:
bcf RCON,IPEN,ACCESS
bsf INTCON,PEIE, ACCESS
bsf INTCON,GIE, ACCESS
(I have also tried the version with interrupt priority switched on,
that's why I have "bsf IPR1,RCIP,ACCESS", howeve this is simply
ignored when " bcf RCON,IPEN,ACCESS" is used).
The result is however, that PIC doesn't call the interrupt routine.
I have a special variable to detect if the routine was ever called:
Code at 0x08:
call HiIrq,FAST
HiIrq:
pop ; According to the errata 80220g.pdf
banksel int_flag
setf int_flag, BANKED
call ser_rx_irq
retfie FAST
The int_flag variable is still equal to 0 (set in the initial code).
However I can see, that the INTCON is set to 0xc5, and that EUSART
receive something on the serial line (RCSTA contains initially 0x90,
than 0x94 - <frame error>, later 0x96 - <frame error & data lost>)
The RCIF is also set (PIR1 contains 0x20), and RCIE as well (PIE1
contains
0x20).
How is it possible, that with INTCON<7> set to 1, INTCON<6> set to 1,
and
both RCIE and RCIF set to '1' the interrupt routine is not called?
The PIC does not hang, as the USB code, which I use for debugging
works
perfectly.
--
TIA & regards,
Wojtek Zabolotny
wzab@ise.pw.edu.pl
PIC 18F4550 - EUSART does not generate interrupts
Started by ●July 30, 2008
Reply by ●July 31, 20082008-07-31
The situation is even worse. This PIC does not respond to any interrupts. I have added: bsf INTCON,INT0IE, ACCESS to the initialization routine and then: HiIrq: pop ; According to the errata 80220g.pdf banksel int_flag setf int_flag, BANKED call ser_rx_irq call int0_irq retfie FAST int0_irq: btfss INTCON,INT0IF,ACCESS return bcf INTCON,INT0IE,ACCESS return What I can see is that INTCON has initially value 0xd5, and then, after I press the button connected to the INT0 line - 0xd7. The HiIrq routine is never called, even though GIE and PEIE bits are set. Does it mean, that this chip is damaged? What else could cause such a problem? Unfortunately I'm currently on my hollidays and this is the only 18F4550 I have with me :-(/
Reply by ●August 2, 20082008-08-02
I have found the following post about similar problems: http://www.motherboardpoint.com/t93255-interrupt-not-firing-on-pic18f.html I checked that in my code (based on the Bradley Minch's USB firmware) I had the _DEBUG_ON_4L option set. After I replaced it with _DEBUG_OFF_4L, the interrupts started to work! I'm quite surprised, that setting of this option breaks interrupts... In the datasheet (39632D.pdf) there is nothing about it... -- Regards, Wojtek







