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 CCS Technical Support

rs232 on PIC12F1840 not working SOLVED
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

rs232 on PIC12F1840 not working SOLVED
PostPosted: Mon Feb 24, 2020 4:38 am     Reply with quote

Hi

I am trying two days already to figure out why my program for rs232 is not working on PIC12F1840.
CCS PCM C Compiler, Version 5.062
The same settings are working on PIC18F26K22.
Code:
/////////////////////////////////////////////////////////////////////
//1840rs232.c rs232 test
/////////////////////////////////////////////////////////////////////
#include <12F1840.h>
#device ADC=10
#FUSES NOWDT,PUT,BROWNOUT,BORV25,NOLVP,MCLR
#FUSES INTRC_IO,PLL
#FUSES NOPROTECT,NOCPD
#use delay(internal=8MHz)
//#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8,stream=PORT1,errors)
#use rs232(baud=9600, UART1, stream=PORT1, errors)
//rs232 RA0=TX;RA1=RX;alternate RA4=TX;RA5=RX
#define LED PIN_A2//flashes ones a second
int LEDcounter;
int tx1switch=0,TXcounter;
#int_TIMER1
void TIMER1_isr(void)
{
   LEDcounter++;
   TXcounter++;
   if(LEDcounter>=10)//500ms
   {
      LEDcounter=0;
      output_toggle(LED);
   }
   if(TXcounter>=40)//2000ms
   {
      TXcounter=0;
      enable_interrupts(INT_TBE);
   }
   set_timer1(15536);
}
#int_RDA
void RDA_isr(void)
{
   delay_cycles(1);
}
#int_TBE
void TBE_isr(void)
{
   switch(tx1switch)
   {
      case 0:
      {
         fputc(0x55,PORT1);
         tx1switch=1;      
      }
      break;
      case 1:
      {
         fputc(0xAA,PORT1);
         tx1switch=2;   
      }
      break;
      case 2:
      {
         fputc(0xFF,PORT1);
         tx1switch=0;
         disable_interrupts(INT_TBE);         
      }
      break;
   }
}   
void main()
{
   SETUP_ADC(NO_ANALOGS);
   PORT_A_PULLUPS(0x08);   
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_2);//65.536 ms overflow;
   enable_interrupts(INT_TIMER1);
   disable_interrupts(INT_RDA);
   disable_interrupts(INT_TBE);
   enable_interrupts(GLOBAL);
   while(TRUE)
   {
      delay_cycles(1);
   }
}

For sure I am doing something wrong, but can't find what.
In the MPLAB simulator the program works correct. I mean the TX is triggered every 2000ms and loading the 3 bytes correct.
I put the counters, LED toggle and the TX start in the Interrupt of TIMER1 for simplicity.
The LED is blinking but no rs232.
The data is sent to the YAT terminal.
The data from PIC18F16K22 is displayed correct.

Please help

Best wishes
Joe


Last edited by gjs_rsdi on Thu Feb 27, 2020 8:06 pm; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Feb 24, 2020 5:49 am     Reply with quote

OK, that PIC uses the APFCON register to control where which pins the UART is connected to (as well as other peripherals). It's in chapter 12 of the datasheet. I'd configure that so you KNOW what it is ! If you're using a 'wizard', THAT could be changing it and never tell you.

And...

I'd cut a very simple 'Echo+' program
something like this....
Code:

main() {
while(true) {
receive a character form the terminal program(getc() )
send it+1, back to the terminal program (putc)
toggle Test LED
}
}

Pressing an 'A' on the PC keyboard should display a 'B' on the PC screen and every other press will lightup the LED.
This code is in the FAQ section of the manual, well, pretty sure it is.


By keeping it simple, you can confirm wiring, connections, timing, etc. that the hardware is 100%.
HaveAchat



Joined: 02 Aug 2015
Posts: 16
Location: Australia

View user's profile Send private message

PostPosted: Mon Feb 24, 2020 6:06 am     Reply with quote

I cant see where you get the data from the RS232 port
I would also recommend an echo to test the connection

Code:
#int_RDA
void RDA_isr(void)
{
   char c = getc(port1);
   putc(c,port1);
}


Everything you type on the RS232 port should come straight back
Ttelmah



Joined: 11 Mar 2010
Posts: 19544

View user's profile Send private message

PostPosted: Mon Feb 24, 2020 7:02 am     Reply with quote

You are not running at the right clock rate:

#FUSES NOWDT,PUT,BROWNOUT,BORV25,NOLVP,MCLR
#FUSES INTRC_IO,PLL

You have the PLL enabled. With the PLL, the 8MHz setting will give
32Mhz.....

The simulators don't check the actual clock rate being used, but on the real
chip it matters.

Get rid of the PLL fuse.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 24, 2020 4:02 pm     Reply with quote

Thank you for posting, Temtronic, Ttelmah and HaveAchat.
I will try to explain myself better and what I have done so far:

PLL was there because I was running the PIC at 32MHz, changed to 8MHz,
I was thinking it may be the problem. Forget to cancel PLL. After out-commenting PLL, I am still getting
PLL_SW in the .LST file fuses. The LED blinks correct, toggle every 500ms with the
hardware, before and after out-commenting PLL.

Regarding the Wizard, I get:
Code:
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8,stream=PORT1,errors)

After it didn't work, I changed it to:
Code:
#use rs232(baud=9600, UART1, stream=PORT1, errors)

The above works smooth with PIC18F26K22 as I mention before. Same PC, same terminal, same cable.

Echoing a sent byte, I done it in the beggining. I changed to send only (TX) as this how
the PIC18F26K22 works, to be sure I don't have problem there.
Tested again as below, using the same TX and RX format as in PIC18F26K22
Code:
#int_RDA
void RDA_isr(void)
{
   rx1w0=fgetc(PORT1);//should be 0x55
   rx1w0=rx1w0+1;
   enable_interrupts(INT_TBE);
}
#int_TBE
void TBE_isr(void)
{
   fputc(rx1w0,PORT1);
   disable_interrupts(INT_TBE);      
}   

Tried again with the bellow settings, still not working, except the LED
Code:
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8,stream=PORT1,errors)

The program below compiles:
Code:
#include <12F1840.h>
#device ADC=10
#FUSES NOWDT,PUT,BROWNOUT,BORV25,NOLVP,MCLR
#FUSES INTRC_IO//,PLL
#FUSES NOPROTECT,NOCPD
#use delay(internal=8MHz)
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8,stream=PORT1,errors)
//#use rs232(baud=9600, UART1, stream=PORT1, errors)
#define LED PIN_A2
int LEDcounter;
int data=0;
#int_TIMER1
void TIMER1_isr(void)
{
   LEDcounter++;
   if(LEDcounter>=10)//500ms
   {
      LEDcounter=0;
      output_toggle(LED);
   }
   set_timer1(15536);
}
#int_RDA
void RDA_isr(void)
{
   data=fgetc(PORT1);
   data=data+1;
   enable_interrupts(INT_TBE);
}
#int_TBE
void TBE_isr(void)
{
   fputc(data,PORT1);
   disable_interrupts(INT_TBE);      
}   
void main()
{
   SETUP_ADC(NO_ANALOGS);
   PORT_A_PULLUPS(0x08);   
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_2);//65.536 ms overflow;
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_RDA);
   disable_interrupts(INT_TBE);
   enable_interrupts(GLOBAL);
   while(TRUE)
   {
      delay_cycles(1);
   }
}

Tested again with the PIC18F26K22 to be sure about the USB/TTL converter and the terminal and it works fine.

Best wishes
Joe
HaveAchat



Joined: 02 Aug 2015
Posts: 16
Location: Australia

View user's profile Send private message

PostPosted: Mon Feb 24, 2020 6:26 pm     Reply with quote

Joe,
I have dim memories of the Transmit Buffer Empty interrupt from long ago.

I thought it fired after the TX buffer had emptied.

It looks like your code is just waiting to run but I could be wrong.
Could you make the change below and see if it helps, its also helping me understand how to do this

Code:
#int_RDA
void RDA_isr(void)
{
   data=fgetc(PORT1);
   fputc(data,PORT1);  // added by John G - immediate echo
   data=data+1;
   enable_interrupts(INT_TBE);
}
#int_TBE
void TBE_isr(void)
{
   fputc(data,PORT1);
   disable_interrupts(INT_TBE);     
}   

Regards,
John G
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Mon Feb 24, 2020 7:39 pm     Reply with quote

Hi John

I tested it with the fputc(data,PORT1); inside the RX interrupt, not working.
I think is also wrong to add this instruction inside the interrupt routine.

Best wishes
Joe
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 24, 2020 9:26 pm     Reply with quote

Look at your .LST file. Look at the code after the #use rs232() statement.
If you have code for a hardware UART, it will look like this:
(Your .LST file format should be set to Symbolic mode for best results).
Code:
..... #use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8,stream=PORT1,errors)
*
0047:  BTFSS  PIR1.RCIF
0048:  GOTO   047
0049:  MOVLB  03
004A:  MOVF   RCSTA,W
004B:  MOVLB  00
004C:  MOVWF  rs232_errors
004D:  MOVLB  03
004E:  MOVF   RCREG,W  // Reads from a hardware register
004F:  MOVWF  @78
0050:  MOVLB  00
0051:  BTFSS  rs232_errors.1
0052:  GOTO   057
0053:  MOVLB  03
0054:  BCF    RCSTA.CREN
0055:  BSF    RCSTA.CREN
0056:  MOVLB  00
*
0062:  BTFSS  PIR1.TXIF
0063:  GOTO   062
0064:  MOVLB  03
0065:  MOVWF  TXREG
....................

If you have code for a software UART, the first part of it will look like this,
with the MOVLW 08 statement:
Code:
.... #use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8, stream=PORT1,errors)
*
0047:  MOVLB  01
0048:  BSF    TRISA.1
0049:  MOVLB  00
004A:  BTFSC  PORTA.1
004B:  GOTO   04A
004C:  MOVLW  08   // Load the bit counter with 8 bits
004D:  MOVWF  @77
004E:  CLRF   @@26
004F:  BSF    @77.7
0050:  GOTO   05F
0051:  BCF    @77.7
0052:  GOTO   05F

The #int_rda interrupt is only supported by a hardware UART.
Which code do you have ?
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Tue Feb 25, 2020 12:59 am     Reply with quote

Thank you for posting PCM Programmer

What I have is the first one, I mean the hardware. It is the same as you posted with:
Code:
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8,stream=PORT1,errors)

and
Code:
#use rs232(baud=9600, UART1, stream=PORT1, errors)

I am using always Symbolic mode after you told me in the past how to do that

Smile

Best wishes
Joe
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Tue Feb 25, 2020 1:59 am     Reply with quote

Hi

To be able to compare apples to apples I made a new program to work with PIC18F26K22 and same hardware with a program that the rs232 works.
Both
Code:
#use delay(clock=64MHz,crystal=16MHz)


The working program have thousands of lines and 7 headers.
From the .LST
PIC18F26K22 project CCP222X1*******WORKING
Code:
.................... #use rs232(baud=9600, UART1, stream=PORT1, errors)
*
001BC:  BTFSS  PIR1.TX1IF
001BE:  BRA    01BC
001C0:  MOVWF  TXREG1
001C2:  RETURN 0
*
002A0:  BTFSS  PIR1.RC1IF
002A2:  BRA    02A0
002A4:  MOVFF  RCSTA1,rs232_errors
002A8:  MOVFF  RCREG1,01
002AC:  BTFSS  rs232_errors.1
002AE:  BRA    02B4
002B0:  BCF    RCSTA1.CREN
002B2:  BSF    RCSTA1.CREN
002B4:  RETURN 0

The new project
PIC18F26K22 project 26K22rs232******NOT WORKING
Code:
.................... #use rs232(baud=9600, UART1, stream=PORT1, errors)
*
000EE:  BTFSS  PIR1.TX1IF
000F0:  BRA    00EE
000F2:  MOVWF  TXREG1
000F4:  GOTO   00FC (RETURN)
*
00104:  BTFSS  PIR1.RC1IF
00106:  BRA    0104
00108:  MOVFF  RCSTA1,rs232_errors
0010C:  MOVFF  RCREG1,01
00110:  BTFSS  rs232_errors.1
00112:  BRA    0118
00114:  BCF    RCSTA1.CREN
00116:  BSF    RCSTA1.CREN
00118:  GOTO   011E (RETURN)

The working project have RETURN 0 at the end of the setting, the not working program have GOTO

Can this be the problem?

The not working rs232, LED blinks correct
Code:
/////////////////////////////////////////////////////////////////////
//26k22rs232 test program
/////////////////////////////////////////////////////////////////////
#include <18F26K22.h>
#device ADC=10
#FUSES NOWDT,NOPBADEN,PUT,BROWNOUT,BORV29
#FUSES PLLEN,NOIESO,NOFCMEN,NOHFOFST,HSH//,INTRC_IO,HSH
#FUSES MCLR,STVREN,NOLVP,NOXINST,NODEBUG
#FUSES NOPROTECT,NOCPD,NOWRT,NOWRTC,NOWRTD
#use delay(clock=64MHz,crystal=16MHz)
#use rs232(baud=9600, UART1, stream=PORT1, errors)
#define flashled PIN_B5
int flashledcnt;
int TXcounter;
int data;
#int_TIMER0
void TIMER0_isr(void)
{
   flashledcnt++;
   TXcounter++;
   if(flashledcnt>=10)
   {
      flashledcnt=0;
      output_toggle(flashled);
   }
   if(TXcounter>=40)
   {
      TXcounter=0;
      enable_interrupts(INT_TBE);
   }   
   set_timer0(15536);
}
#int_TBE
void TBE_isr(void)
{
   fputc(data,PORT1);
   disable_interrupts(INT_TBE);      
}      
#int_RDA
void RDA_isr(void)
{
   data=fgetc(PORT1);
   data=data+1;
   enable_interrupts(INT_TBE);
}
void main()
{
   setup_adc_ports(NO_ANALOGS);   
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16);//65.536 ms overflow
   enable_interrupts(INT_TIMER0);
   enable_interrupts(INT_RDA);
   disable_interrupts(INT_TBE);
   enable_interrupts(GLOBAL);
   while(TRUE)
   {
      delay_cycles(1);
   }
}


Best wishes
Joe
Ttelmah



Joined: 11 Mar 2010
Posts: 19544

View user's profile Send private message

PostPosted: Tue Feb 25, 2020 2:37 am     Reply with quote

No, the GOTO is quite correct.
The compiler uses this when the function is only being called from one place.
Fractionally quicker.

OK. Now it looks as if the clock should be right. The compiler normally
'overrides' incorrect clock fuse settings when you use 'internal=xx' , in the
clock setup, but I was trying to look for anything obvious that 'might' cause
a problem.
Can you count ten flashes, with a stopwatch, and verify that this does give
ten seconds?.
A clock error, would explain things not working.
Add the line to disable the comparator. setup_comparator(NC_NC);
Historically a lot of chips have issues with this having a higher priority
than other functions on the pins.

Will have to go back and have a play and see what 5.062 actually does,
but what you post now does look as if it should work.

You do realise the serial will be on C6/C7?.

Also, I'd initialise these three variables:

int flashledcnt=0;
int TXcounter=0;
int data='A';

Otherwise when you start the program, it could send straight away
depending on what just happens to be in the memory, and could send
a garbage character every 2 seconds.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Tue Feb 25, 2020 6:16 pm     Reply with quote

SOLVED Smile Smile Smile
I started thinking what is the difference between the working and not working projects.
The difference is that in the working project I have many calls in the main and the not working just the 1 cycle delay.
I was always afraid from delays that an interrupt will not be served during the delay time.
The problem was this:
Code:
   while(TRUE)
   {
      delay_cycles(1);
   }

I started with delay of 1000ms down to 1us and all works OK
Code:
   while(TRUE)
   {
      delay_us(1);
   }

I want to thank everybody that contributed to this topic, I learned a lot Smile
Regarding your last post Ttelmah, I implemented all but didn't help. I know that I am working with C6 and C7 as I designed the board.

I still have a question as my knowledge is very limited:
WHY? I mean why is not working with the one cycle delay?

Best wishes
Joe
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 26, 2020 6:28 am     Reply with quote

hmmm....
you do this in the ISR..

disable_interrupts(INT_TBE);

and never enable it again in main()

just curious as to why
Ttelmah



Joined: 11 Mar 2010
Posts: 19544

View user's profile Send private message

PostPosted: Wed Feb 26, 2020 6:59 am     Reply with quote

He enables it when he writes the character in INT_RDA.
It has to be disabled if there is nothing more to send otherwise it'll keep
triggering.
Must admit cannot see why it'd not service interrupts with the loop only
having a delay_cycles(1);
Would have to look at the assembler. Guess that the optimiser is changing
this and the effect is somehow to interfere with the interrupt handling.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 26, 2020 6:32 pm     Reply with quote

Thank you for posting Ttelmah and Temtronic.

I was happy too early Sad
The PIC18F26K22 rs232 works. I made it similar as possible the the PIC12F1840
Code:
/////////////////////////////////////////////////////////////////////
//26k22rs232 test program
/////////////////////////////////////////////////////////////////////
#include <18F26K22.h>
#device ADC=10
#FUSES NOWDT,NOPBADEN,PUT,BROWNOUT,BORV29
#FUSES PLLEN,NOIESO,NOFCMEN,NOHFOFST,INTRC_IO//HSH
#FUSES MCLR,STVREN,NOLVP,NOXINST,NODEBUG
#FUSES NOPROTECT,NOCPD,NOWRT,NOWRTC,NOWRTD
#use delay(internal=32MHz)
#use rs232(baud=9600, UART1, stream=PORT1, errors)
#define LED PIN_B5
int LEDcounter=0;
int TXcounter=0;
int data=0x0A;
#int_TIMER1
void TIMER1_isr(void)
{
   LEDcounter++;
   TXcounter++;
   if(LEDcounter>=10)//500ms
   {
      LEDcounter=0;
      output_toggle(LED);
   }
   if(TXcounter>=40)
   {
      TXcounter=0;
      enable_interrupts(INT_TBE);
   }   
   set_timer1(15536);
}
#int_TBE
void TBE_isr(void)
{
   fputc(data,PORT1);
   disable_interrupts(INT_TBE);      
}      
#int_RDA
void RDA_isr(void)
{
   data=fgetc(PORT1);
   data=data+1;
   enable_interrupts(INT_TBE);
}
void main()
{
   SETUP_ADC(NO_ANALOGS);
   setup_comparator(NC_NC);   
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);//65.536 ms overflow;
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_RDA);
   disable_interrupts(INT_TBE);
   enable_interrupts(GLOBAL);
   while(TRUE)
   {
      delay_us(10);
   }
}

The 12F1840 not working:
Code:
/////////////////////////////////////////////////////////////////////
//1840rs232.c rs232 test
/////////////////////////////////////////////////////////////////////
#include <12F1840.h>
#device ADC=10
#FUSES NOWDT,PUT,BROWNOUT,BORV25,NOLVP,MCLR
#FUSES INTRC_IO,PLL
#FUSES NOPROTECT,NOCPD
#use delay(internal=32MHz)
//#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8,stream=PORT1,errors)
#use rs232(baud=9600, UART1, stream=PORT1, errors)
#define LED PIN_A2//flashes ones a second
int LEDcounter=0;
int TXcounter=0;
int data=0x0A;
#int_TIMER1
void TIMER1_isr(void)
{
   LEDcounter++;
   TXcounter++;
   if(LEDcounter>=10)//500ms
   {
      LEDcounter=0;
      output_toggle(LED);
   }
   if(TXcounter>=40)
   {
      TXcounter=0;
      enable_interrupts(INT_TBE);
   }   
   set_timer1(15536);
}
#int_TBE
void TBE_isr(void)
{
   fputc(data,PORT1);
   disable_interrupts(INT_TBE);      
}
#int_RDA
void RDA_isr(void)
{
   data=fgetc(PORT1);
   data=data+1;
   enable_interrupts(INT_TBE);
}   
void main()
{
   SETUP_ADC(NO_ANALOGS);
   setup_comparator(NC_NC);   
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);//65.536 ms overflow;
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_RDA);
   disable_interrupts(INT_TBE);
   enable_interrupts(GLOBAL);
   while(TRUE)
   {
      delay_us(10);
   }
}

PIC1F1847 from the PIC12F1840 family don't work also:
Code:
/////////////////////////////////////////////////////////////////////
//1847rs232.c rs232 test
/////////////////////////////////////////////////////////////////////
#include <16F1847.h>
#device ADC=10
#FUSES NOWDT,PUT,BROWNOUT,BORV25,NOLVP,MCLR
#FUSES INTRC_IO,PLL
#FUSES NOPROTECT,NOCPD
#use delay(internal=32MHz)
//#use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8,stream=PORT1,errors)
#use rs232(baud=9600, UART1, stream=PORT1, errors)
#define LED PIN_B5//flashes ones a second
int LEDcounter=0;
int TXcounter=0;
int data=0x0A;
#int_TIMER1
void TIMER1_isr(void)
{
   LEDcounter++;
   TXcounter++;
   if(LEDcounter>=10)//500ms
   {
      LEDcounter=0;
      output_toggle(LED);
   }
   if(TXcounter>=40)
   {
      TXcounter=0;
      enable_interrupts(INT_TBE);
   }   
   set_timer1(15536);
}
#int_TBE
void TBE_isr(void)
{
   fputc(data,PORT1);
   disable_interrupts(INT_TBE);   
}   
#int_RDA
void RDA_isr(void)
{
   data=fgetc(PORT1);
   data=data+1;
   enable_interrupts(INT_TBE);
}
void main()
{
   SETUP_ADC(NO_ANALOGS);
   setup_comparator(NC_NC_NC_NC);   
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);//65.536 ms overflow;
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_RDA);
   disable_interrupts(INT_TBE);
   enable_interrupts(GLOBAL);
   while(TRUE)
   {
      delay_us(10);
   }
}

The LED works correctly on all.
I made a compare in the CCS IDE and they are similar except controllers name and fuses for PIC18F26K22.
The .LST files of the PIC12F1840 and PIC16F1847 are similar, the PIC18F26K22 completely different or I don't understand enough to judge.
Code:
//********************************************
#device PIC18F26K22
.................... #use rs232(baud=9600, UART1, stream=PORT1, errors)
*
000EE:  BTFSS  PIR1.TX1IF
000F0:  BRA    00EE
000F2:  MOVWF  TXREG1
000F4:  GOTO   00FC (RETURN)
*
00104:  BTFSS  PIR1.RC1IF
00106:  BRA    0104
00108:  MOVFF  RCSTA1,rs232_errors
0010C:  MOVFF  RCREG1,01
00110:  BTFSS  rs232_errors.1
00112:  BRA    0118
00114:  BCF    RCSTA1.CREN
00116:  BSF    RCSTA1.CREN
00118:  GOTO   011E (RETURN)
//********************************************
#device PIC16F1847
.................... #use rs232(baud=9600, UART1, stream=PORT1, errors)
*
0051:  BTFSS  PIR1.TXIF
0052:  GOTO   051
0053:  MOVLB  03
0054:  MOVWF  TXREG
*
005B:  BTFSS  PIR1.RCIF
005C:  GOTO   05B
005D:  MOVLB  03
005E:  MOVF   RCSTA,W
005F:  MOVLB  00
0060:  MOVWF  rs232_errors
0061:  MOVLB  03
0062:  MOVF   RCREG,W
0063:  MOVWF  @78
0064:  MOVLB  00
0065:  BTFSS  rs232_errors.1
0066:  GOTO   06B
0067:  MOVLB  03
0068:  BCF    RCSTA.CREN
0069:  BSF    RCSTA.CREN
006A:  MOVLB  00
//*********************************************
#device PIC12F1840
.................... #use rs232(baud=9600, UART1, stream=PORT1, errors)
*
0051:  BTFSS  PIR1.TXIF
0052:  GOTO   051
0053:  MOVLB  03
0054:  MOVWF  TXREG
*
005B:  BTFSS  PIR1.RCIF
005C:  GOTO   05B
005D:  MOVLB  03
005E:  MOVF   RCSTA,W
005F:  MOVLB  00
0060:  MOVWF  rs232_errors
0061:  MOVLB  03
0062:  MOVF   RCREG,W
0063:  MOVWF  @78
0064:  MOVLB  00
0065:  BTFSS  rs232_errors.1
0066:  GOTO   06B
0067:  MOVLB  03
0068:  BCF    RCSTA.CREN
0069:  BSF    RCSTA.CREN
006A:  MOVLB  00
//*******************************************


By the way Temtronic, I am enabling the TBE in the RX interrupt as Ttelmah wrote and when the counter getting to 2000ms. It is the same as in the PIC18F26K22 that works in both cases.
Have no idea what happening Sad

Best wishes
Joe
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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