I need an additional serial port for my PIC 18F4550

Status
Not open for further replies.

ashwinvsinha

Newbie level 3
Joined
Apr 2, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
Guyz I need atleast 2 serial ports to interface my ultrasonic sensor and vibrator with the PIC 18f4550 (Its 40 Pin DIP IC)
can anyone tell me the programme code for configuring an additional pin to be configured as serial port ( "i think its called soft uart -dont know") plz help
 

You can use a multiplexer for this purpose also.
Or you can use Software UART.

Digital Multiplexer is best way but if you want Soft UART tell me which Compiler you are using i will give code for that.
 
You can use a multiplexer for this purpose also.
Or you can use Software UART.

Digital Multiplexer is best way but if you want Soft UART tell me which Compiler you are using i will give code for that.

Hello thanks alot for your speedy reply
I am using MP Lab XC8 compiler for my PIC 18F4550
i would prefer software UART, kindly give me the program code for the said compiler.
Once again thanks alot :-D
 

Software uart functions are available with MPLABC18 Compiler, and the functions are written in assembly, you can import those function by copy paste and put those into your project, and then use them with xc8 compiler.

- - - Updated - - -

Have a look at these threads also

http://www.microchip.com/forums/m675843-print.aspx
http://www.microchip.com/forums/m677168.aspx
http://www.microchip.com/forums/m653620.aspx


If you are not able to do so.
i will do it for you, but will take some time.
 

Hello i need help
this is the program i wrote to get soft uart for my PIC 18f4550
#include <stdio.h>
#include <stdlib.h>
#include<p18f4550.h>
#define __18F4550
#include<conio.h>
#include <plib.h>
#define _XTAL_FREQ 20000000
void DelayTXBitUART(void)
{
_delay(509); //9600 baud:
}
void DelayRXHalfBitUART(void)
{
_delay(252); //9600 baud:
}
void DelayRXBitUART()
{
_delay(507); //9600 baud:
}
void main (void)
{
unsigned int count,i=0,a,b,x[10],y[10],j=0,data;
TXSTA =0x04;
RCSTAbits.SPEN=1;
TRISD =0x00;
TRISC =0xff;
TRISB =0x20;
RCSTA=0X90;
ADCON1=0x0f;
SPBRG=129;
while( 1 )
{
here1:
while(PIR1bits.RCIF==0);
if(RCSTAbits.OERR==1)
{
RCSTAbits.CREN=0;
RCSTAbits.CREN=1;
}
x=RCREG;
i++;
if (RCREG!=13)
goto here1;
x[0]=(x[0]-48);
x[0]=(x[0]*100);
x[1]=(x[1]-48);
x[1]=(x[1]*10);
x[2]=(x[2]-48);
a=(x[0]+x[1]+x[2]);

OpenUART();
here2:
data =0;
data = ReadUART();
y[j]=data;
j++;
if(data!=13)
goto here2;
y[0]=(y[0]-48);
y[0]=(y[0]*100);
y[1]=(y[1]-48);
y[1]=(y[1]*10);
y[2]=(y[2]-48);
b=(y[0]+y[1]+y[2]);
}
}

i am not getting o/p in the above program, what is wrong in that... kindly check
NOTE: it works well before the line openUART() .....but its giving me error in proteus like logic contention
plz tell me what else do i need to edit in the above program to get soft UART
Thanks alot again
 

Upload your while project in an compressed zip folder.

It will be easy to check then.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…