CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18LF14K50 with compiler 4.120 bug ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
NePe



Joined: 21 Jun 2011
Posts: 9

View user's profile Send private message

PIC18LF14K50 with compiler 4.120 bug ?
PostPosted: Tue Jun 21, 2011 4:05 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 21, 2011 4:51 pm     Reply with quote

Post a test program so we can see what you're doing. Example:
http://www.ccsinfo.com/forum/viewtopic.php?t=45032&start=3
If possible, make it be smaller than that (maybe without the flashing LED
routine).
NePe



Joined: 21 Jun 2011
Posts: 9

View user's profile Send private message

PostPosted: Tue Jun 21, 2011 6:40 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 21, 2011 8:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 21, 2011 10:36 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jun 22, 2011 1:36 am     Reply with quote

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?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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