New Microsoft Word Document1

  • Uploaded by: Minh Nguyen
  • 0
  • 0
  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View New Microsoft Word Document1 as PDF for free.

More details

  • Words: 432
  • Pages: 5
/************************** Nursultan Urmatbek DEC 02, 2018 LCD with zlog controls output string and shift left and right ***************************/

#include<ez8.h>

//function prototype void init_ports(void); void init_LCD(void); void cmd_write(unsigned char cmd); void data_write(unsigned char data); void delay(unsigned int);

unsigned char watch; unsigned char cmd; unsigned char data;

void main(void) { unsigned char msg[] = "URMATBEK ", *pmsg = msg;

unsigned char msg2[] = "SOLANGON ", *pmsg2 = msg2;

init_ports(); init_LCD();

//cmd_write(0x40); while (*pmsg != '\0')

// loops through the string until it reaches null

{ //watch = *pmsg; data_write(*pmsg++); //delay(50); } // end of while loop, works

cmd_write(0xC0);

// DDRAM address set

delay(20); // set to second line, 0x40 with no enable

while (*pmsg2 != '\0')

// loops until null

{ //watch = *pmsg2; data_write(*pmsg2++);

//delay(50); }

cmd_write(0xCE);

// set DDRAM address to line 2, postion 14

delay(20);

//data_write('0'); //delay(20); return; } // end of main

// display '0' zero

void init_ports(void) { // initialize port D0 - D7: Enable = D0, R/W = D1, RS = D2 // we are using the 3 least sig. bits for this program

PDADDR = 0x02; PDCTL = 0x00;

PDADDR = 0x01; PDCTL = 0x00;

PDADDR = 0x03; PDCTL = 0x00;

PDADDR = 0x00;

/* Initialize port E, main communication port with the LCD */

PEADDR = 0x02; PECTL = 0x00;

PEADDR = 0x01; PECTL = 0x00;

PEADDR = 0x03; PECTL = 0x00;

PEADDR = 0x00;

return; } // end of Initialization of Ports

void init_LCD(void) { cmd_write(0x38);

// 8-bit, 2 line, 5x7 font size

cmd_write(0x0F);

// set Display/Cursor/Blinking

cmd_write(0x01);

// clears Display

//cmd_write(0x14);

// set cursor to shift right after a character is displayed

cmd_write(0x06);

// enter entry mode

return; } // end of Initial of LCD

void cmd_write(unsigned char cmd) // RS is set low, command is stored on the bus, enable is pulsed high for a short duration { PDOUT = 0x00;

// RS=0, R/W=0, Enable=0; Command write mode

PEOUT = cmd;

// send cmd to LCD data bus

//strobe E PDOUT = 0x01; delay(30);

PDOUT = 0x00;

return;

// set Enable = 1 // software debouncer

// set Enable = 0

}

void delay(unsigned int dtime) { unsigned int t;

for(;dtime>0;dtime--) { for(t=220;t>0;t--); } return; }

void data_write(unsigned char data) // RS is set high, data is stored on the bus, enable is pulsed high for a short duration { PDOUT = 0x04;

// RS=1, R/W=0, Enable=0; Data write mode

PEOUT = data;

// send data to LCD

// strobe E PDOUT = 0x05; delay(30);

PDOUT = 0x04;

return; }

// RS=1, R/W=0, Enable=1; // software debouncer

// strobe Enable to latch data

Related Documents


More Documents from ""

Thoa Thuan 3 Ben
October 2019 26
November 2019 30
Medical Term-revised.docx
November 2019 16