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

How to Create a software UART ?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Thu Jun 05, 2008 2:14 pm     Reply with quote

Quote:


Do you get just one "c6", or over and over again? Don't you mean BYTE c=0b10001000;? If you want to send a recognizeable character, specify it as '?' rather than in binary or hex.

Another thing you should test is to put a 1 second delay between each character you send out.

And why are you discarding the first character that you read?

And why are you using while(kbhit()) instead of if(kbhit())?



made the changes and some modifications, now the code looks like this,

Code:


//18f4680 side/////////////////
#use rs232(baud=4800, xmit=PIN_C1,rcv=PIN_C0, STREAM=HOSTPC)
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7, STREAM=USER,parity=N,stop=1)

void main()
   {
   while(1)
   {
    BYTE c=0b10001000;
    fputc(c, HOSTPC);
    fputc(c,USER);// this is the hardware Rs232, so that I can compare the outputs between my LCD and the serial terminal.
    delay_ms(1000);
   }}

//16F877a side//

void main()
      {
      byte c;
     
      lcd_init();
      c=fgetc(HOSTPC);
      while(TRUE)
      {
      if(kbhit())
      {
     
      c=fgetc(HOSTPC);
      printf(lcd_putc,"%x",c);
      delay_ms(1000);
      }



I did not understand what you meant by '?' .

Here are the outputs I am getting

On the LCD its : "fa" with a delay of 1 sec.

On the serial port : "^e" with a delay of 1 sec.

I personally think this is a baud rate issue, but I may be wrong, any ideas?

Cheers

Tranz
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

PostPosted: Thu Jun 05, 2008 3:34 pm     Reply with quote

tranz wrote:


Here are the outputs I am getting

On the LCD its : "fa" with a delay of 1 sec.

On the serial port : "^e" with a delay of 1 sec.

I personally think this is a baud rate issue, but I may be wrong, any ideas?

Yes, it could be. You have not shown the directives that tell the CCS compiler what the clock rate is so it can figure the baudrate. And it would be easier if you transmitted a printable character. 0b10001000 is not. Why don't you just send c = 'A' or something like that so you can see it on the serial port? If you have a scope you can check the baudrate.

Robert Scott
Real-Time Specialties
tranz



Joined: 10 Feb 2007
Posts: 78

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Mon Jun 09, 2008 9:41 am     Reply with quote

Thanks Robert,

It now works, a 'A' was sent across the software UART and the serial port, and both displayed the same thing.

Now I face a similar problem, when i try to send the data through the internet and transfer this data over to the 2nd micro controller (16F877A).

The 18F4680 is connected to the internet and is acting like a client, and my computer is acting like the server. When I send data through my computer over to 18F4680 via Ethernet, the data is displayed over the 18F4680's hardware serial port (via hyper terminal), but the data does not seem to be sent over to the 16F877A via software UART.

Although I am using the same concept which worked for the previous program.

Any suggestions?

Thanks

tranz
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 Previous  1, 2
Page 2 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