Vermes
Advanced Member level 4
This design is an USART module which can operate with display 16x1. This device was implemented on PIC16F84A. The main assumption of this project was to crate a module which allows the communication with such a display via USART. In order to send data to the display, you only have to give instruction of start of the transmission „[„. Instruction „]” informs the mictocontroller that there is no more data for display. Additional instruction „#” allows for deleting the screen. Because the display 16x1 is divided into two pieces (8 characters each), the microcontroller pays attention to correct transition of an inscription to the other half of the display. When the entire display is full and it receives 17 character, the screen is deleted and the 17 character appeats as 1 character on the display.
Communication of the microcontroller with the PC:
Microcontroller PIC16F84A communicated with the computer using port COM. You need to use MAX232 to adapt the voltage of TTL (5V) of the microcontroller to the standard RS232 (12V) which is on the port COM.
Communication of the microcontroller with another microcontroller:
Microcontroller PIC16F84A communicates with another microcontroller using USART.
Electric schematic:
Data transmission protocol:
Tab.1 Control instructions
Code ASCII Instruction
[ start of data receiving
] stop of data receiving
# deleting the display
Algorithm of the program:
Code of the program:
Link to original thread - Moduł USART dla wyświetlacza 16x1 zrealizowany na PIC16F84A
Communication of the microcontroller with the PC:
Microcontroller PIC16F84A communicated with the computer using port COM. You need to use MAX232 to adapt the voltage of TTL (5V) of the microcontroller to the standard RS232 (12V) which is on the port COM.
Communication of the microcontroller with another microcontroller:
Microcontroller PIC16F84A communicates with another microcontroller using USART.
Electric schematic:
Data transmission protocol:
Tab.1 Control instructions
Code ASCII Instruction
[ start of data receiving
] stop of data receiving
# deleting the display
Algorithm of the program:
Code of the program:
Code:
/**
* Wyswietlanie na LCD danych pobranych
* przez USART.
*/
*
#include <16F84.h>
#fuses XT,NOPROTECT,NOWDT
*
#use delay(clock=4000000)
*
//RX RA2 PIN 1
//TX RA3 PIN 2
#use rs232(baud=300,parity=N,xmit=PIN_A3,rcv=PIN_A2,bits=9)
*
#include "wlcd.c"
*
main() {
char c;
char i=0;
*
/*
//Informacja o sterowaniu wyslana na rs232
printf("\fLCD OK\n");
printf("[ - begin\n");
printf("] - end\n");
printf("# - clear\n");
*/
*
//inicjacja lcd
lcd_init();
*
//napis testowy na lcd
lcd_putc("\fLCD 2.2");
*
delay_ms(800);
lcd_putc("\f");
*
//glowna petla programu
for(;;){
*
//pobranie znaku z usart
c = getc();
*
//komenda - czyszczenie wyswietlacza
if (c=='#'){
i = 0;
lcd_putc("\f");
}
*
//komenda - rozpoczecie wyswietlania
if (c == '['){
for(;;){
//pobranie znaku do wyswietlenia
c = getc();
*
//jesli nie jest to znak konca transmisji dla wyswietlania, to znak na ekran
if (c!=']'){
*
//jesli koniec linii (polowa ekranu) to przejscie na 2 polowe ekranu
if (i==8){ lcd_putc("\n"); }
//jesli koniec ekranu to zaczynamy od nowa
if (i==16){ lcd_putc("\f"); i=0; }
*
//dodanie znaku do wyswietlacza
lcd_putc(c);
i++;
}
//byl znak konca transmisji na wyswietlacz
if (c==']') {
break;
}
}
}
}
}
*
Link to original thread - Moduł USART dla wyświetlacza 16x1 zrealizowany na PIC16F84A