Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Uart for connecting 2 PIC 16f877A

Status
Not open for further replies.

Rooney_04

Member level 2
Joined
Oct 2, 2010
Messages
42
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,577
hi
Basically i m working for a project. So i m using two PIC 16f877A which one for transmitter and another one for receiver. the problem is how could i send binary data through the transmitter and receive by the receiver? I m using CCS C COMPILER?
thanks hope members can help...
 

Thanks you very much. but i m working in CCS C. it will be easy for me if it in CCS S because i m still new PIC programming and Uart programming.
 

Hi,
This is a sample code with 16F877:
It receives a byte from UART and then sends it back:

Code:
#include <16F877.h>
#fuses HS, NOWDT
#use delay(clock=10000000) //10MHz
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)
void main(void){
   char k;
   while (1){
      k = getchar(); //recive the character
      putchar(k); //echo it back
}

You could build on from this. Using the #use RS232 directive, you can use the getchar(), putchar() and printf() functions.

Hope this helps.
Tahmid.

---------- Post added at 15:10 ---------- Previous post was at 15:10 ----------

I'm not very good with CCS, that's as far as my knowledge with CCS goes.
 

Hi,
This is a sample code with 16F877:
It receives a byte from UART and then sends it back:

Code:
#include <16F877.h>
#fuses HS, NOWDT
#use delay(clock=10000000) //10MHz
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)
void main(void){
   char k;
   while (1){
      k = getchar(); //recive the character
      putchar(k); //echo it back
}

You could build on from this. Using the #use RS232 directive, you can use the getchar(), putchar() and printf() functions.

Hope this helps.
Tahmid.

---------- Post added at 15:10 ---------- Previous post was at 15:10 ----------

I'm not very good with CCS, that's as far as my knowledge with CCS goes.


Thanks. It this for the receiver or transmitter coding?
 

Hi,
This is basically a sample for receiver and transmitter.
Code:
k = getchar(); //receive the character
This receives data through UART.
Code:
putchar(k); //echo it back
This sends data through UART.

Hope this helps.
Tahmid.
 

Hi,
This is basically a sample for receiver and transmitter.
Code:
k = getchar(); //receive the character
This receives data through UART.
Code:
putchar(k); //echo it back
This sends data through UART.

Hope this helps.
Tahmid.

hi
i just need to transmit data one way only. basically receiver PIC will receive data and execute the routine(controlling dc motor speed). hence the PIC transmitter will transmit data only. So how could do this?
 

Hi,
Tx:
Code:
#include <16F877.h>
#fuses HS, NOWDT
#use delay(clock=10000000) //10MHz
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)
void main(void){
   unsigned char k;
   k = 0;
   while (1){
      k++;
      putchar(k);
      delay_ms(500);
   }
}
Rx:
Code:
#include <16F877.h>
#fuses HS, NOWDT
#use delay(clock=10000000) //10MHz
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,stream=RS232,bits=8)
void main(void){
   unsigned char k;
   PORTB = 0;
   TRISB = 0;
   while (1){
      k = getchar(); //receive the character
      PORTB = k;
   }
}

I'm not exactly sure about the codes as I don't use CCS, but they should be like that.

Hope this helps.
Tahmid.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top