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

PCWH 4.095, 18F46J50, use rs232 not enabling serial port

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



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

PCWH 4.095, 18F46J50, use rs232 not enabling serial port
PostPosted: Wed Aug 12, 2009 1:53 pm     Reply with quote

I set up my code with the usual

#use rs232 ....

and tried to send some serial data out but it would not go. I discovered that the TXEN bit in TXSTA1 was not enabled. I am confused because in the old 3.249 compiler with 18f8622, it was always enabled.

Did something change.

Also I noticed that "#use STANDARD_IO()" does not seem to be the default. My I/O would not work until I declared this explicitily.
Comments?
_________________
-Pete
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 12, 2009 1:58 pm     Reply with quote

Post a short, but complete "Hello World" program that shows the
problem. The program must be compilable. Example:
http://www.ccsinfo.com/forum/viewtopic.php?t=39874&start=1
Guest








PostPosted: Thu Aug 13, 2009 7:43 am     Reply with quote

Works:
Code:

#include <18F46j50.h>
#fuses HSPLL,NOWDT,NOPROTECT,PLLDIV3
#use delay(clock=48000000)
#use rs232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, ERRORS, parity=N, bits=8)

char txsta1;
#LOCATE txsta1 = 0xFAD

char txreg1;
#LOCATE txreg1 = 0xFAE

void main(void)
{
  txsta1 = txsta1 | 0x20;

  while (TRUE)
  {
    txreg1 = 'R';  //putc and printf do not work
  }
}



Fails, Program Hangs on txreg1 = ‘R’; and nothing is sent out, also putc and printf do not work
If you stop the debugger it always stops at #use rs232...

Code:

#include <18F46j50.h>
#fuses HSPLL,NOWDT,NOPROTECT,PLLDIV3
#use delay(clock=48000000)
#use rs232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, ERRORS, parity=N, bits=8)

char txsta1;
#LOCATE txsta1 = 0xFAD

char txreg1;
#LOCATE txreg1 = 0xFAE

void main(void)
{
  //txsta1 = txsta1 | 0x20;

  while (TRUE)
  {
     txreg1 = 'R';
  }
}


Note also that #use RS232 did not put value in for baud rate generator, I had to calculate the proper value.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 13, 2009 2:40 pm     Reply with quote

I think that CCS just copied the register map from the 18F45J10 to
the 18F46J50 when they created that PIC in Devices4.dat file. The
problem is that the register maps are not the same. So the serial
port code for the 18F46J50 won't work. It's possible that the entire
register map is messed up. I didn't check other modules, such as
SPI, etc.

Here are the differences that I see in the .LST files (for vs. 4.095).
for the registers used in the UART initialization code:
Code:

Register   18F45J10    18F46J50               
address    reg. name   reg. name           

0xFB8      BAUDCON     ECCP2AS (wrong)
0xFAF      SPBRG       RCREG1  (wrong)
0xFB0      SPBRGH      Not in .LST file
0xFAC      TXSTA       RCSTA1 (wrong)
0xFAB      RCSTA       SPBRG2 (wrong)

Those are the register addresses that appear in the .LST files for the
18F45J10 and the 18F46J50. They are correct for the 18F45J10, but
not for the 18F46J50, because the register map is different for that PIC.

If you tell CCS support about this bug, and if your compiler maintenance
has run out, I believe they will let you download the fixed version when
they release it. So I advise you to report it to them. Give them your
customer number so they know you own the compiler.

Also, vs. 4.096 has the same problems.
pfournier



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

PostPosted: Thu Aug 13, 2009 3:03 pm     Reply with quote

Thanks, I never even considered looking in that area!
I have sent a note to CCS.
_________________
-Pete
Leachj
Guest







PIC18F46J50 serial port not working
PostPosted: Wed Nov 11, 2009 3:51 am     Reply with quote

I am running version 4.099 of the CCS compiler and also have had problems getting the PIC18F46J50 to output serial data. I have found that the RCSTA registers are incorrectly defined in the device table. To correct this go to the device table editor which should be found in C:\Program Files\PICC\chipedit.exe. Find the 18F46J50 part on the left hand table and select it, then open the UART line in the centre table. The table for RCSTA originally showed FAB,F6B and this should be changed for FAC,F9C. Save the changes. Recompiling then produced working code!
Hope this helps all those who are experiencing similar problems.
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