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.

Serial I/O routines in C? (no UART!)

Status
Not open for further replies.

Laurie

New Member
Hi all,
i'm trying to output a number of bytes (only 6 or 7) on one pin from a 16f684, to be recieved on one pin another 16f684.....i'm writing my program in C, and cant find much info on this at all for C programmers.....are there any downloadable subroutines that i could #include into my code that would let me just send a byte or two at a time to a 'send' function....??? (and a 'recieve' function for the other PIC that could copy the recieved bytes into my own variables/from which i could copy the recieved bytes as they come in.)


any help or info on where i could find help would be great :)

i'm using PICC Lite, MPLAB, and a PICKIT2 programmer........and it really does have to be done by 1 pin at each end.....

thanks very much,
L

{edit, forgot to explain that i need a 'recieve' function too...}
 
Last edited:
yes...PIC C Lite does have a 'serial' file in the samples directory, but it seems really complex, and uses RA2&3 as I/O, whereas i need to use RC3....
is it as simple as changing the relevent TRIS and PORT registers to change these to RC3?....i still dont understand how i'd use the functin tho; theres no obvious 'copy your byte here, then call 'sendfuncxxxx' explanation, and no readme...

thanks for the quick response, and sorry if this is all really basic....
L
 
There should be two #define's near the top of the code to select which IO lines are used. Change them from what they are to what you want to use.

The low level IO function is putc(). It may have a slightly different name like soft_putc() but it is there. It will put whatever byte/char you send it out on the IO pin you setup.

{
char x;

x = 'A';
putc(x);
}


If you look into how printf works you will see that you can use it with the software UART too.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top