Search

Wednesday, September 3, 2014

USART Transmission With PIC18F4520

Title:USART Transmission With PIC18F4520

Program:


//Author : Palak Patel
//Contact No:9173211683
//Title:usart transmission
//Platform: PIC18f4520
//Software:MPLAB

#include<p18f4520.h>
void delay();

void main()
{
                unsigned char palak[]="Palak Patel";
                unsigned int i=0;
                TRISC=0x00;

                SPBRG=31;         
                TXSTAbits.CSRC=1;                 //Master Mode
                TXSTAbits.TX9=0;                   //8 Bit
                TXSTAbits.TXEN=1;                //Transmit enabled
                RCSTAbits.SPEN=1;
                TXSTAbits.SYNC=0;                //Asynchronous Mode
                TXSTAbits.SENDB=0;              //Sync Break transmission completed
                TXSTAbits.BRGH=0;                //High Speed
                while(palak[i]!='\0')
                {
                               
                                while(PIR1bits.TXIF==0);// TMRT Empty
                                TXREG=palak[i];       //Transmit buffer
                                i++;
                                delay();
                }
while(1);
}

void delay()
{
                unsigned int j;
                for(j=0;j<100;j++);

}
Simulation:




For Basic Electronics Kindaly follow this Link:

No comments:

Post a Comment