____________________________________________________________________________________________________
- What is serial COM ?- A computer transfers data by two methods called serially and parallelly, 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-
- If data transmitted one way a time, it is referred to as half duplex.
- If data can go both ways at a time, it is full duplex.
Following are the pin connectors that are used to connect microcontroller with PCs.
- Serial data communication uses two methods:
- 1. Synchronous method transfers a block of data at a time
- Asynchronous method transfers a single byte at a time
- Asynchronous serial data communication is widely used for character-oriented transmissions
(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
- The start bit is always one bit, but the stop bit can be one or two bits. Due to the extended ASCII Characters, 8-bit ASCII data is common. In modern PCs, the use of one stop bit is standard. Assuming that we are transferring a text file of ASCII characters using 1 stop bit, we have a total of 10 bits for each character including 8 character with 1 start and 1 stop bit.
- The rate of data transfer in serial data communication is stated in bps (bits per second). Another widely used terminology for bps is baud rate. It is modem terminology and is defined as the number of signal changes per second. In modems, there are occasions when a single change of signal transfers several bits of data.
- The data transfer rate of given computer system depends on communication ports incorporated into that system
- IBM PC/XT could transfer data at the rate of 100 to 9600 bps
- Pentium-based PCs transfer data at rates as high as 56Kbps
- In asynchronous serial data communication, the baud rate is limited to 100Kbps
- In RS232 protocol, a 1 is represented by -3 to -25 V, while a 0 bit is +3 to +25 V, making -3 to +3 undefined and support TTL logics.
- Microcontroller used CMOS logics generally, so we need a line driver such as the MAX232 chip which is required to convert RS232 voltage levels to CMOS levels, and vice versa.
- Following diagram is shown interfacing diagram of ATmega32 with PC and use of MAX232 IC.
- To allow data transfer between the PC and an microcontroller system without any error, we must make sure that the baud rate of microcontroller system matches the baud rate of the PC’s COM port.
- Applications- Communication between computer and microcontroller.
Click Here : Understanding of RS232 protocol and setting up baud rate
Click Here : Registers used in serial com programming
1. Circuit Diagram Of serial communication of pic18f458 microcontroller
_______________________________________________________________________________________________________
2. Circuit Diagram Of serial communication of pic18f458 microcontroller With LCD
_______________________________________________________________________________________________________
1. Program of serial communication of pic18f458 microcontroller
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:- CONTROL(PIC18F458) SEND "WWW.FIRMCODE.COM" THROUGH RS232 PROTOCOL ******************************************************/ /* header file used in this program is already included in software microC pro for pic*/ void delay(); void serial_ini(); void serial_tr(unsigned char x); void main() { TRISC=0XFF; serial_ini(); while(1) { serial_tr('W'); delay(); serial_tr('W'); delay(); serial_tr('W'); delay(); serial_tr('.'); delay(); serial_tr('F'); delay(); serial_tr('I'); delay(); serial_tr('R'); delay(); serial_tr('M'); delay(); serial_tr('C'); delay(); serial_tr('O'); delay(); serial_tr('D'); delay(); serial_tr('E'); delay(); serial_tr('S'); delay(); serial_tr('.'); delay(); serial_tr('C'); delay(); serial_tr('O'); delay(); serial_tr('M'); delay(); serial_tr(0X0D); delay(); delay(); delay(); delay(); delay(); } } void delay() { int i,j; for(i=0;i<100;i++) for(j=0;j<500;j++); } void serial_ini() { TXSTA=0X20; SPBRG=15; TXSTA.TXEN=1; RCSTA.SPEN=1; } void serial_tr(unsigned char x) { TXREG=x; while(PIR1.TXIF==0); }
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
_______________________________________________________________________________________________________
2. Program of SERIAL COMMUNICATION Of PIC18F458 with LCD
In this program data entered from the hyper terminal of PC or Laptop is appeared on the LCD connected to the controller
/****************************************************** www.firmcodes.com DEVELOPED BY:- FIRMWARE DEVELOPER WHAT PROGRAM DO:- BLINK LEDs ON PORT2 ******************************************************/ /* header file used in this program is already included in software microC pro for pic*/ #define rs portb.RB4 #define rw portb.RB5 #define en portb.RB6 #define lcd portd int rec; void lcd_ini(); void lcd_display(unsigned int); void cmd(unsigned char); void lcd_str(unsigned char*); void serial_ini() char serial_re(); void serial_tr(unsigned char x); void main() { int i=0; TRISC.RC7=1; TRISC.RC6=0; TRISD=0X00; TRISB=0X00; serial_ini(); lcd_ini(); while(1) { i++; serial_re(); lcd_display(rec); if(i==16) cmd(0xc0); if(i==32) { cmd(0x01); i=0; } } } void lcd_display(unsigned int x) { lcd=x; rs=1; rw=0; en=1; delay_ms(100); en=0; } void cmd(unsigned char m) { lcd=m; rs=0; rw=0; en=1; delay_ms(10); en=0; } void lcd_ini() { cmd(0x38); cmd(0x0e); cmd(0x01); cmd(0x06); cmd(0x80); } void lcd_str(unsigned char *str) { while(*str!='\0') { lcd_display(*str); str++; } } void serial_ini() { RCSTA=0X90; SPBRG=15; TXSTA.TXEN=1; RCSTA.SPEN=1; } char serial_re() { while(PIR1.RCIF==0); rec=RCREG; return rec; } void serial_tr(unsigned char x) { TXREG=x; while(PIR1.TXIF==0); }
PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)
_______________________________________________________________________________________________________
Content for the tab VIDEO