Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PIC16F887 - Internal Clock...
- #define _XTAL_FREQ 8000000;
- #include <htc.h>
- __CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_INTRC_CLKOUT);
- #define E RA0
- #define RS RA1
- #define RW RA2
- /**********************************************************/
- const char ScreenData[38] = {
- 0x41, //A 0
- 0x42, //B 1
- 0x43, //C 2
- 0x44, //D 3
- 0x45, //E 4
- 0x46, //F 5
- 0x47, //G 6
- 0x48, //H 7
- 0x49, //I 8
- 0x4A, //J 9
- 0x4B, //K 10
- 0x4C, //L 11 //CHARACTER DEFINITIONS!
- 0x4D, //M 12
- 0x4E, //N 13 //ADD 32 TO GET LOWERCASE!
- 0x4F, //O 14
- 0x50, //P 15
- 0x51, //Q 16
- 0x52, //R 17
- 0x53, //S 18
- 0x54, //T 19
- 0x55, //U 20
- 0x56, //V 21
- 0x57, //W 22
- 0x58, //X 23
- 0x59, //Y 24
- 0x5A, //Z 25
- 0x20, //SPACE 26
- 0x3A, //: 27
- 0x30, //0 28
- 0x31, //1 29
- 0x32, //2 30
- 0x33, //3 31
- 0x34, //4 32
- 0x35, //5 33
- 0x36, //6 34
- 0x37, //7 35
- 0x38, //8 36
- 0x39 //9 37
- };
- /**********************************************************/
- void Busy_Flag()
- {
- RW = 1;
- TRISB=1;
- _delay(900);
- while(RB7==1)
- {
- //Loop until finished
- }
- RW=0; //always return to write mode...
- TRISB=0;
- }
- void Write_LCD()
- {
- E=1;
- _delay(5000);
- E=0;
- Busy_Flag();
- }
- void AddressDisplay(unsigned char c)
- {
- RS=0;
- PORTB=c;
- Write_LCD();
- RS=1;
- }
- /**********************************************************/
- programname()
- {
- float a = 0x00;
- RS = 1;
- PORTB=ScreenData[2];
- Write_LCD();
- PORTB=ScreenData[14]+32;
- Write_LCD();
- PORTB=ScreenData[12]+32;
- Write_LCD();
- PORTB=ScreenData[15]+32;
- Write_LCD();
- PORTB=ScreenData[14]+32;
- Write_LCD();
- PORTB=ScreenData[18]+32;
- Write_LCD();
- PORTB=ScreenData[19]+32;
- Write_LCD();
- PORTB=ScreenData[4]+32;
- Write_LCD();
- PORTB=ScreenData[17]+32;
- Write_LCD();
- PORTB=ScreenData[26];
- Write_LCD();
- PORTB=ScreenData[26];
- Write_LCD();
- PORTB=ScreenData[21];
- Write_LCD();
- PORTB=ScreenData[4]+32;
- Write_LCD();
- PORTB=ScreenData[17]+32;
- Write_LCD();
- PORTB=ScreenData[27];
- Write_LCD();
- PORTB=ScreenData[29];
- Write_LCD();
- AddressDisplay(0x40);
- RS = 0;
- }
- /********************************************************/
- lcd_init()
- {
- PORTB = 0x0F;
- Write_LCD();
- _delay(500);
- PORTB = 0x01;
- Write_LCD();
- _delay(500);
- }
- /********************************************************/
- //2000 = 1ms
- main()
- {
- TRISA=0;
- TRISB=0;
- TRISC=0;
- TRISD=0;
- TRISE=0;
- ANSEL=0;
- PORTA=0;
- PORTB=0;
- PORTC=0;
- PORTD=0;
- PORTE=0;
- E=1;
- lcd_init();
- programname();
- while(1){}
Add Comment
Please, Sign In to add comment