Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

scrolling text in lcd for mc9s12e128 some small problem please help

Status
Not open for further replies.

omani

New Member
hi how are you!?

i try many times to edit my code but problem it does not work it just shift little

this is my code ,,withonly the text showing without any scrolling

can you tell me how i can add the fuction for scrolling the text please ??


#include <hidef.h>
#include <mc9s12e128.h>
#pragma LINK_INFO DERIVATIVE "SampleS12"
#define setEN 0x04 // 0000 0100 - activate enable bit only
#define cmd 0x00 // set rs=0(command) and rw=0
#define dat 0x01 // set rs=1(data) and rw=0


void initPort(void);
void initPort(void) {
PORTK = 0x00; //clear and set PORT K
DDRK = 0xFF;
PTP=0x00; //and P as output port
DDRP=0XFF;
}
void delay(unsigned int);
void delay(unsigned int x) //delay - approx 1ms delay
{
unsigned int y;
while(x>0){
for(y=2750;y>0;y--);
x--;
}
}

void LCDWrite(unsigned char, unsigned char);
void LCDWrite(unsigned char val, unsigned char mode) {
PTP = setEN | mode;
delay(1);
PORTK = val;
delay(1);
PTP = mode;
delay(1);
}
void initLCD(void);
void initLCD(void){
char x;
unsigned char init[]={0x30,0x30,0x30,0x38,0x0C,0x01,0x06};
for(x=0;x<7;x++) {
LCDWrite(init[x],cmd);


}
}
void LCD_String(unsigned char* , unsigned char);
void LCD_String(unsigned char* str, unsigned char addr){
char x;
addr = addr | 0x80;
LCDWrite(addr,cmd);
for(x=0;str[x]!='\0';x++) {
LCDWrite(str[x],dat);
}
}
void main(void) {
unsigned char name[]="Omaini ";

delay(1000);
initPort();
initLCD();
EnableInterrupts;
LCD_String(name,0);
for(;;) {;}
}


all thanks
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top