|
|
View previous topic :: View next topic |
Author |
Message |
Besugo
Joined: 12 Mar 2011 Posts: 20
|
PIC18F27J13 Problems (big problems) |
Posted: Thu Apr 07, 2011 4:37 am |
|
|
Hi.
Big issues in PIC18F27J13. Can't Interrupt, map pins and so on.
As for the most basic stuff, the external interrupts, i've gone to bit level, and done this:
Code: |
#include <18F27J13.h>
#fuses HS,NODEBUG,NOXINST,NOPROTECT,NOWDT,NOCLOCKOUT,NOIOL1WAY
#fuses NOPLLEN,NOSTVREN,NOXINST,NODEBUG,NOFCMEN
#fuses NOIESO,NODSBOR,NODSWDT,NOWPFP,NOWPCFG,NOWPDIS
#use delay(internal=8MHz)
#byte INTCON = 0xFF2
#bit RBIF = INTCON.0
#bit INT0IF = INTCON.1
#bit TMR0IF = INTCON.2
#bit RBIE = INTCON.3
#bit INT0IE = INTCON.4
#bit TMR0IE = INTCON.5
#bit PEIE = INTCON.6
#bit GIE = INTCON.7
#int_ext
void isr()
{
output_toggle(pin_A0);
}
void main()
{
INTCON = 0x00;
RBIF = 0;
INT0IF = 0;
TMR0IF = 0;
RBIE = 0;
INT0IE = 1;
TMR0IE = 0;
PEIE = 0;
GIE = 1;
while(1)
{
output_high(pin_A1);
}
}
|
- Can't clear RBIF flag
- INT0IE is set but interrupt don't fire
Tried the same code on a PIC18F2580 and it worked perfectly.
Any thoughts? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 07, 2011 10:40 am |
|
|
If you suspect a compiler bug, always post your compiler version. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Thu Apr 07, 2011 2:39 pm |
|
|
Some obvious comments:
You can never clear RBIF, if the source of this interrupt is true. This is why in the handler for this interrupt, you must read portB. So if the portB latch, happens to be waking up in a different state to the actual input pins, this bit won't clear. Read section 10.3 of the data sheet. The code to clear RBIF, is:
Code: |
dummy=input_b();
delay_cycles(1);
RBIF=0;
|
This applies to all PIC's, being able to clear RBIF, without reading the port, is 'luck'.....
Get rid of the HS fuse. That the code runs at all, is again 'luck'. You can't have two oscillator selections made. You are using the internal oscillator, and selecting the external high speed crystal oscillator.
On this chip, you have PPS. You need first to ensure that the ADC is not using RB0, and make sure that no re-mappable peripheral is using RP3, to allow B0 to function as INT0.
Best Wishes |
|
|
Besugo
Joined: 12 Mar 2011 Posts: 20
|
|
Posted: Sun Apr 10, 2011 5:07 am |
|
|
Thank you, all the issues are resolved with an ugrade to compiler version 4.114. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|