Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Connecting 2 PIC 16f877A

Status
Not open for further replies.

Rooney_04

New Member
i
i did some programming for the transmitter PIC. From here, may i know how i could send data to other PIC. How could i send binary data from this coding? Planning on using push button to send the data. Example binary data 0001 to transmit to other PIC
thanks

Code:
#include <16F877a.h>
#include <stdio.h>
#include <stdlib.h>
#use delay(clock=20000000)
#fuses hs, noprotect, nowdt, nolvp
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,st ream=RS232,bits=


#byte portb=6
#byte portc=7
#byte portd=8

void main()
{
   unsigned char k;
   k = 0;  
   while (true){

     if (!input(pin_B1));
     putchar(k);
     delay_ms(500);
   };
}
 
Last edited by a moderator:
That PIC has SPI, I2C, and USART peripherals, so pick your poison. Are you trying to connect a PIC directly to another PIC -- as in by wire?

Just read the datasheet for whichever type you'd like to use (I'd just suggest the USART module), and then come back and ask questions on anything you are getting hung up on.

It's really a matter of what you are trying to do. If it's communication over a wire, then the above will do, though I would have to ask why if you aren't just doing it for your own practice or school work.

If you want to do wireless communication, there are a few different ways to approach it depending on your constraints and requirements.
 
for simulation purpose i would like to connect by wire. the problem is that i m confused about how to send binary data. Such as i would to send the binary data "0001" 0101" "0111" and "0011"
 
Rooney,

You've got to do some more homework first. The correct direction in the TRIS port must be configured, the correct configuration must be set in the ANSEL register, and then if you use the USART module you've got to set the right baud rate and activate the module. The datasheet will tell you everything and probably give you example code in assembly language. If you have questions from there, ask them. I've got some ASM SPI examples that I could possibly post when I get home if you are interested in SPI.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top