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

PIC24FJ16 Uart1 Problem

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



Joined: 19 Mar 2010
Posts: 18

View user's profile Send private message

PIC24FJ16 Uart1 Problem
PostPosted: Sun Mar 21, 2010 12:02 pm     Reply with quote

I tried to send character "HELLO" To PC. I used PIC uart1. I am getting scrambled characters. I am getting this hex: (A8 A5 AC AC AF)
The code is:
Code:

#include <24FJ16GA002.h>
#fuses HS,PROTECT,NOWDT
#use delay(crystal=7372800 )
#use rs232(baud=115200, UART1,xmit=PIN_B8, rcv=PIN_B9, bits=8)

void main()
{

 while (1) {

    delay_ms(500);
    printf ("HELLO"); // print to serial port
    delay_ms(1000);               // do nothing for half a second
   
 while (1);
 }
}
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Mar 21, 2010 1:00 pm     Reply with quote

What's your PCD version? The code doesn't compile with V4.104 or V4.105. These versions expect a #PIN_SELECT
statement for the UART pins. Older versions are apparently generating a software UART with these settings. You should
force a hardware UART, requires #PIN_SELECT, and check again.
chandra



Joined: 19 Mar 2010
Posts: 18

View user's profile Send private message

PostPosted: Mon Mar 22, 2010 12:56 am     Reply with quote

I am using PCD version 4.084.I need a example program for this chip.where can I find?
Thanks.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Mar 22, 2010 1:25 am     Reply with quote

The correct #pin_select syntax is this
Code:
#pin_select U1TX=PIN_B8
#pin_select U1RX=PIN_B9
#use rs232(baud=115200, UART1, bits=8)

It should be mentioned, that #pin_select is still not working correctly up to PCD V4.105 with some PIC24 chips, but it
seems to be understood for your chip with V4.084. Otherwise, you'd need to program peripheral pin select SFRs yourself.
chandra



Joined: 19 Mar 2010
Posts: 18

View user's profile Send private message

PostPosted: Mon Mar 22, 2010 2:02 am     Reply with quote

I used these lines, but now I am getting scrambled letters. I am getting the hex value is:A8 39 CA 9D. It is likely a baudrate problem.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Mar 22, 2010 4:12 am     Reply with quote

Also the software UART used in your previous setup should have worked correctly. You should verify, that the
crystal is correct and your processor is actually working at specified frqeuency.
monsters_inc



Joined: 18 Jan 2010
Posts: 14

View user's profile Send private message

PostPosted: Mon Mar 22, 2010 10:05 am     Reply with quote

Hi. try #fuses XT,PROTECT,NOWDT.
XT - 3mhz to 10 mhz for PCD.

Best Regards.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Mar 22, 2010 11:05 am     Reply with quote

Quote:
Hi. try #fuses XT,PROTECT,NOWDT.

Yes, XT rather than HS is correct. But it's used by PCD automaticly due to the low crystal frequency.
chandra



Joined: 19 Mar 2010
Posts: 18

View user's profile Send private message

PostPosted: Wed Mar 24, 2010 12:43 am     Reply with quote

Code:

#fuses PR, HS,PROTECT,NOWDT

Now ok.
Thanks for all.
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