|
|
View previous topic :: View next topic |
Author |
Message |
NePe
Joined: 21 Jun 2011 Posts: 9
|
PIC18LF14K50 with compiler 4.120 bug ? |
Posted: Tue Jun 21, 2011 4:05 pm |
|
|
Hi!
I want to set an interrupt to the RA5 pin but its not working.
I found in the .lst file that the enable_interrupts(INT_RA5) line is incorrect in ASM:
Code: | .................... enable_interrupts(INT_RA5);
0A1C: BSF FF2.3
0A1E: BSF F7A.5
|
The last asm command set the IOCB(F7A) register instead of IOCA(F79) register.
I'm trying to fix it with the following code but the interrupt still not working:
Code: |
enable_interrupts(GLOBAL);
#ASM
BSF 0xFF2.3
BSF 0xF79.5
#ENDASM
|
In the .lst file this is looks like this:
Code: |
.................... enable_interrupts(GLOBAL);
0A1C: MOVLW C0
0A1E: IORWF FF2,F
.................... #ASM
.................... BSF 0xFF2.3
0A20: BSF FF2.3
.................... BSF 0xF79.5
0A22: BSF F79.5
.................... #ENDASM
|
When i try to read the RA5 pin in the main loop the readed values are correct.
What am i doing wrong? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
NePe
Joined: 21 Jun 2011 Posts: 9
|
|
Posted: Tue Jun 21, 2011 6:40 pm |
|
|
Here it is:
Code: |
#include <18LF14K50.h>
#FUSES WDT512, CPUDIV1, LP, NOPLLEN, NOPCLKEN, BORV30, NOIESO, NOMCLR, NOLVP, BBSIZ1K, NOXINST
#use delay(clock=16Mhz, RESTART_WDT)
#use rs232(baud=9600, parity=N, xmit=PIN_C3, rcv=PIN_C4, bits=8, ERRORS, STREAM=RSGSM)
void main() {
setup_oscillator(OSC_16MHZ | OSC_TIMER1 | OSC_31250 | OSC_PLL_OFF);
enable_interrupts(GLOBAL);
enable_interrupts(INT_RA5);
// #ASM
// BSF 0xFF2.3
// BSF 0xF79.5
// #ENDASM
while (1) {
}
}
#int_RA
void RA_isr(void) {
if (!input(PIN_A5)) {
fputs("TEST", RSGSM);
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 21, 2011 8:31 pm |
|
|
Pin A5 is one of the oscillator pins. You need to disable it as an oscillator pin.
Quote: |
#FUSES WDT512, CPUDIV1, LP, NOPLLEN, NOPCLKEN, BORV30,
NOIESO, NOMCLR, NOLVP, BBSIZ1K, NOXINST |
The LP fuse is for a 32.768 KHz watch crystal, but you're using the
internal oscillator. So you need to change LP to INTRC_IO. In addition
to using the correct fuse, it will also allow pin A5 to be used as an i/o pin. |
|
|
NePe
Joined: 21 Jun 2011 Posts: 9
|
|
Posted: Tue Jun 21, 2011 10:36 pm |
|
|
Hi, you are right!
The problem is the LP fuse instead of INTRC_IO.
As i mentioned i'm tested the RA5 as input when the LP fuse is used and it reads the correct value:
Code: |
#include <18LF14K50.h>
#FUSES WDT512, CPUDIV1, LP, NOPLLEN, NOPCLKEN, BORV30, NOIESO, NOMCLR, NOLVP, BBSIZ1K, NOXINST
#use delay(clock=16Mhz, RESTART_WDT)
#use rs232(baud=9600, parity=N, xmit=PIN_C3, rcv=PIN_C4, bits=8, ERRORS, STREAM=RSGSM)
void main() {
setup_oscillator(OSC_16MHZ | OSC_TIMER1 | OSC_31250 | OSC_PLL_OFF);
while (1) {
if (!input(GSM_RI)) {
fputs("TEST", RSGSM);
}
}
|
The enable_interrupts(INT_RA5); is still has a bug in the compiler, but when i use my asm code instead of it, all works well!
Thanks for your help. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Jun 22, 2011 1:36 am |
|
|
The Register Address error sounds like a bug in the compiler's chip database. A regular problem with new added processors.
Have you reported the bug to CCS support so they can fix it for the next release? |
|
|
|
|
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
|