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

Communicating two pic microcontrollers using UART

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



Joined: 24 Apr 2011
Posts: 14

View user's profile Send private message

Communicating two pic microcontrollers using UART
PostPosted: Wed May 04, 2011 2:44 pm     Reply with quote

I am trying to communicate two pic16f690 microcontrollers using UART. I have given my test code for both the receiver and transmitter. For testing purposes in the receive side I connected LEDs to all the pins of PORTC but no LED turns on when I run this code.

RECEIVER:
Code:

#include<16f690.h>
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_B7, rcv=PIN_B5, bits = 8)
 
int8 c;
void main(void)
{
   c = getc();
   delay_ms(1000);
   output_c( c );
   while(1);
}


TRANSMITTER:
Code:

#include <16F690.H>
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_B7, rcv=PIN_B5, bits = 8)

void main(void)
{
   putc(0xFF);   
}
temtronic



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

View user's profile Send private message

PostPosted: Wed May 04, 2011 4:28 pm     Reply with quote

some items..

Your trasmitter code sends 0xFF once then goes to sleep..

You need to creat a continuous loop of sending a byte, then waiting say 1 second, and repeat forever.

I would suggest incrementing the data from 0x00 to 0xff to verify that it really works.Sending the same data is not a good test.

Also you should add 'errors' to the use Rs232(...) preprocessor directive.

Be sure that both xmt,rcv and gnds are connected properly
Also use appropriate current limiting resistors with the LEDs!
ALPL



Joined: 29 Mar 2009
Posts: 30

View user's profile Send private message

PostPosted: Thu May 05, 2011 12:00 pm     Reply with quote

Hi , the code cannot work at all. On the receiver side I suggest to use an ISR to catch any incoming data and interpret them in the main function in the while(1)-loop.

As already mentioned: on the sender side send continuously a byte eg every second.
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