____________________________________________________________________________________________________
What is serial COM ? A computer transfers data by two methods called serially and paralleled, both have its own merits and demerits according to application. Here we discuss only about serial communication. In serial com data are transfers bit by bit from transmitter to receiver. About & Types serial COM- Following are the pin connectors that are used to connect microcontroller with PCs. (1) Each character is placed in between start and stop bits, this is called framing (8-bit = single character) (2) Block-oriented data transfers use the synchronous method Applications Communication between computer and microcontroller. _______________________________________________________________________________________________________ _______________________________________________________________________________________________________ In this program data entered from the hyper terminal of PC or Laptop is appeared on the LCD connected to the controller _______________________________________________________________________________________________________ Content for the tab VIDEO
Click Here : Understanding of RS232 protocol and setting up baud rate
Click Here : Registers used in serial com programming
1. Circuit Diagram Of RS232 Protocol Of ARM7 (LPC2148)
2. Circuit Diagram Of RS232 Protocol Of ARM7 (LPC2148) With LCD
1. Program of RS232 Protocol Of ARM7 (LPC2148)
In this program controller send “www.firmcodes.com” to PC or Laptop and it will display on the hyper terminal of PC or Laptop
/******************************************************
www.firmcodes.com
DEVELOPED BY:- FIRMWARE DEVELOPER
WHAT PROGRAM DO:- DATA SEND FROM ARM7(LPC21XX) THROUGH
RS232 PROTOCOL AND DISPLAY DATA ON PC
******************************************************/
#include<lpc21xx.h>
unsigned char rec;
void pll();
void serial_ini();
void serial_transmit(unsigned char x);
void delay(int x);
int main()
{
PINSEL0 = 0x00000005;
IO0DIR=0XFFFFFFFF;
serial_ini();
pll();
while(1)
{
serial_transmit('W'); // call transmit function
delay(100); // calling of delay function
serial_transmit('W'); // call transmit function
delay(100); // calling of delay function
serial_transmit('W'); // call transmit function
delay(100); // calling of delay function
serial_transmit('.'); // call transmit function
delay(100); // calling of delay function
serial_transmit('F'); // call transmit function
delay(100); // calling of delay function
serial_transmit('I'); // call transmit function
delay(100); // calling of delay function
serial_transmit('R'); // call transmit function
delay(100); // calling of delay function
serial_transmit('M'); // call transmit function
delay(100); // calling of delay function
serial_transmit('C'); // call transmit function
delay(100); // calling of delay function
serial_transmit('O'); // call transmit function
delay(100); // calling of delay function
serial_transmit('D'); // call transmit function
delay(100); // calling of delay function
serial_transmit('E'); // call transmit function
delay(100); // calling of delay function
serial_transmit('S'); // call transmit function
delay(100); // calling of delay function
serial_transmit('.'); // call transmit function
delay(100); // calling of delay function
serial_transmit('C'); // call transmit function
delay(100); // calling of delay function
serial_transmit('O'); // call transmit function
delay(100); // calling of delay function
serial_transmit('M'); // call transmit function
delay(100); // calling of delay function
serial_transmit(0x0d); // call transmit function
delay(400);
delay(400);
}
}
void pll()
{
/*PLL IS CONFIGURED TO GET 60HZ pCLK*/
PLLCFG=0X24; // SET PSEL=2 AND MSEL=5
PLLCON=0X01; //PLL IS ACTIVE BUT NOT YET CONNECT
PLLFEED=0XAA; //FEED SEQUENCE
PLLFEED=0X55; //FEED SEQUENCE
while((PLLSTAT & 0X400)==0); //WAIT FOR FEED SEQUENCE TO BE INSERTED
PLLCON=0X03; // PLL HAS BEEN ACTIVE AND BEING CONNECTRD
VPBDIV=0X00; // SET PCLK SAME AS FCCLK
PLLFEED=0XAA; //FEED SEQUENCE
PLLFEED=0X55; //FEED SEQUENCE
}
/* SERIAL INITILIZATION*/
void serial_ini()
{
U0LCR =0x83;
U0DLM=0X00;
U0DLL=0X5e;
U0FDR=0X52;
U0LCR =0x03;
}
void serial_transmit(unsigned char x)
{
U0THR =x; // LOAD DATA IN U0THR REGISTER
while ((U0LSR & 0x40)==0); // WAIT FOR DATA TRANSMISSION
U0LSR|=0X40;
}
void delay(int x)
{
int i,j;
x=x*10;
for(i=0;i<x;i++)
for(j=0;j<350;j++);
}
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
2.Program Of RS232 Protocol Of ARM7 (LPC2148) With Lcd
/******************************************************
www.firmcodes.com
DEVELOPED BY:- FIRMWARE DEVELOPER
WHAT PROGRAM DO:- DATA SEND FROM PC BY RS232 PROTOCOL IS
DISPLAYED ON LCD CONNECTED WITH ARM7(LPC2148)
******************************************************/
#include<lpc21xx.h>
#define LCD (0xff<<16)
#define RS (1<<13)
#define RW (1<<14)
#define EN (1<<15)
void delay_fv(unsigned int x,int y);
void lcd_display(unsigned int x);
void cmd(unsigned char m);
void lcd_ini();
unsigned char rec;
void pll();
void serial_ini();
char serial_re();
int main()
{
PINSEL0 = 0x00000005;
PINSEL1 = 0x00000000;
IO0DIR=0XFFFFFFFF;
serial_ini();
pll();
lcd_ini();
while(1)
{
serial_re();
lcd_display(rec);
}
}
void delay_fv(unsigned int x,int y)
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<y;j++);
}
void lcd_display(unsigned int x)
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(x<<16);
IO0SET|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,10);
IO0CLR|=EN;
delay_fv(10,10);
}
void cmd(unsigned char m)
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(m<<16);
IO0CLR|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,100);
IO0CLR|=EN;
delay_fv(100,10);
}
void lcd_ini()
{
cmd(0X38);
cmd(0X0e);
cmd(0X06);
cmd(0X01);
cmd(0X80);
}
void pll()
{
/*PLL IS CONFIGURED TO GET 60HZ pCLK*/
PLLCFG=0X24; // SET PSEL=2 AND MSEL=5
PLLCON=0X01; //PLL IS ACTIVE BUT NOT YET CONNECT
PLLFEED=0XAA; //FEED SEQUENCE
PLLFEED=0X55; //FEED SEQUENCE
while((PLLSTAT & 0X400)==0); //WAIT FOR FEED SEQUENCE TO BE INSERTED
PLLCON=0X03; // PLL HAS BEEN ACTIVE AND BEING CONNECTRD
VPBDIV=0X00; // SET PCLK SAME AS FCCLK
PLLFEED=0XAA; //FEED SEQUENCE
PLLFEED=0X55; //FEED SEQUENCE
}
void serial_ini()
{
U0LCR =0x83;
U0DLM=0X00;
U0DLL=0X5e;
U0FDR=0X52;
U0LCR =0x03;
}
char serial_re()
{
while ((U0LSR & 0x01)==0); // wait untill complete data is received
rec=U0RBR;
return rec;
}
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)