You are on page 1of 4

START

Initialize variables TRISC0=1;unsigned int i;


Main Flow Chart char ReadUART = 0;char StatusReceived = 0;
INTCON = 0x00;

GfnUsartPinConfigure() _ Configure USART


GfnBuadRateSet(); - Baud Rate 9600 select
GfnUsartInit(); - Initialize USART

Delay

CAN_Port_Init(); - Initialise CAN Ports


InitECAN();
Send message CAN Initialised using
GfnUsartTransmitString("CAN Initialised\n\r")

No
Chk if PortC.01 is Wait
free

Yes

Transmit using ECAN_Transmit();


Message Transmitted
GfnUsartTransmitString("Message Transmitted\n\r");

END

IF EOC=1 , then Conversion from Analog


i/p to digital/p is done
Function void GfnUsartPinConfigure(void)

START

Yes
initializations are done here

RCSTA |= 0x80; Enable the Serial Port.

TRISC &= 0xBF; Make Tx pin as output

TRISC |= 0x80; Make Rx pin as Input

END

Function void GfnBuadRateSet(void)

START

Baud Rate setting is done here

SPBRG = 25 - Assign SPB Reg to 25 which sets the


Baud Rate to 9.6kps

END
Function void GfnUsartInit(void)

START

Initialize USART for Transmission

TXSTA &= 0xBF -- Clear TX9


TXSTA &= 0xEF -- Clear SYNC bit
TXSTA &= 0xFB -- Clear BRGH
TXSTA |= ~0xFB -- Set BRGH
TXSTA |= 0x20 -- Set TXEN i.e. ,Transmission Enabled

Initialize USART for Reception


RCSTA &= 0xBF -- Clear
RCSTA |= 0x10 -- Then Set to Enable Continuous Receive

END

Function GfnUsartTransmitt(char byte)

START

Initialize variable i = 0
Initialize CHARACTER TXREG to be received
variable

Wait till the TXIF is cleared

Wait till PIR1 is cleared

END
START

Initialize variable i = 0
Initialize CHARACTER TXREG to be received
variable

Function GfnUsartTransmitString(char *str)


Wait till the TXIF is cleared

Wait till PIR1 is cleared

Increment to the next character to be


transmitted

END

You might also like