int main(void)
{
int val=0;
ClcdInit();
Uart0Init(); // Initialize UART module at 9600 bps
DelayMs(10500);
ClcdClear() ;
ClcdGoto(2,1);
ClcdPutS_P("Welcome");
_DelayMs(30050); //A delay of 1 second
ClcdClear();
while(1)
{
ClcdGoto(2,1);
ClcdPutS_P("Current Stop is");
_DelayMs(1000);
ClcdGoto(2,2);
ClcdPutS_P("lonavala");
_DelayMs(2000);
ClcdClear();
Uart0PutS("Bus No:MH12 777") ;
_DelayMs(500);
Uart0PutS("Via express highway") ;
_DelayMs(500);
Uart0PutS("TIME:10:10A");
_DelayMs(500);
_DelayMs(500); //A lil delay
} // End While
} // End main
void _DelayMs(unsigned int count)
{
unsigned int j,k;
for (j=0;j<count;j++)
{
for (k=0;k<6000;k++)
{
__asm
{
nop;
nop;
}
}
}
}
void Uart0Init (void) // Initialize Serial Interface
{
PINSEL0 |= 0x00000005; //Enable RxD0 and TxD0
U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bit
U0DLL = 97; // 9600 Baud Rate @ 15MHz VPB Clock
U0LCR = 0x03; // DLAB = 0
}
void Uart0PutS(unsigned char *str) //A function to send a string on UART0
{
while(*str)
{
Uart0PutCh(*str++);
}
}
void Uart0PutCh (unsigned char ch) // Write character to Serial Port
{
while (!(U0LSR & 0x20));
U0THR = ch;
}
unsigned char Uart0GetCh (void) // Read character from Serial Port
{
while (!(U0LSR & 0x01));
return (U0RBR);
}
void ClcdInit(void)
{
IODIR0 |= (unsigned long)(DATA_PORT); //initialize D4:D7 pins as output
IODIR0 |= ((unsigned long)(1)<<CTRL_RS); //initialize RS pins as output
IODIR0 |= ((unsigned long)(1)<<CTRL_EN); //initialize EN pins as output
_CLEAR_EN(); //clear EN
_CLEAR_RS(); //clear RS
_ClcdDelayMs(300);
ClcdSendByte(0X03,0); //Configure bus width as 8-bit
_ClcdDelayMs(50);
ClcdSendByte(0X02,0); //Configure bus width as 4-bit, 1 line,5X7 dots
_ClcdDelayMs(50);
ClcdSendByte(0X28,0); //Configure bus width as 4-bit, 2 line,5X7 dots
_ClcdDelayMs(50);
ClcdSendByte(0X10,0); //Cursor move and Shift to left
_ClcdDelayMs(1);
ClcdSendByte(0x0D,0); // DisplayOn,CursorOff
_ClcdDelayMs(1);
ClcdSendByte(0x06,0); // EntryMode,Automatic Increment - No Display shift.
_ClcdDelayMs(1);
ClcdSendByte(0x01,0); //Clear Display and set address DDRAM with 0X00
_ClcdDelayMs(5);
}
void ClcdSendByte(unsigned char byte,unsigned char type)
{
_CLEAR_EN();
if(type==_TYPE_DATA)
{
_SET_RS(); // Selects data Register for read / write
}
else if(type==_TYPE_CMD)
{
_CLEAR_RS(); // Selects cmd Register for write
}
_ClcdDelay45Us();
IOCLR0 |= DATA_PORT; //Clear Data Port
IOSET0 |= ((((unsigned long)byte >> 4) & 0x0F)<<D4);//Send byte to Data port
_EnToggle();
_ClcdDelay45Us();
IOCLR0 |= DATA_PORT; //Clear Data Port
IOSET0 |= (((unsigned long)byte & 0x0F)<<D4); //Send byte to Data port
_EnToggle();
_ClcdDelay45Us();
}
void ClcdPutS_P( char *str)
{
while(*str) //Check for valid character
{
ClcdSendByte(*str++,_TYPE_DATA);//Send out the current byte pointed to
}
}
Raspberry Training
void ClcdGoto(unsigned char x,unsigned char y)
{
switch(y)
{
case 1:
// position for line 1
y=0x80 ;
break;
case 2:
// position for line 2
y=0xC0 ;
break;
default:
break;
}
ClcdSendByte((x-1+y),_TYPE_CMD);
}
void _ClcdDelayMs(unsigned int count)
{
volatile unsigned int j,k;
for (j=0;j<count;j++)
{
for (k=0;k<400;k++)
{
__asm
{
nop;
nop;
}
}
void _ClcdDelay45Us(void)
{
volatile unsigned int k;
for(k=0;k<409;k++)
{
__asm
{
nop;
}
}
}
{
int val=0;
ClcdInit();
Uart0Init(); // Initialize UART module at 9600 bps
DelayMs(10500);
ClcdClear() ;
ClcdGoto(2,1);
ClcdPutS_P("Welcome");
_DelayMs(30050); //A delay of 1 second
ClcdClear();
while(1)
{
ClcdGoto(2,1);
ClcdPutS_P("Current Stop is");
_DelayMs(1000);
ClcdGoto(2,2);
ClcdPutS_P("lonavala");
_DelayMs(2000);
ClcdClear();
Uart0PutS("Bus No:MH12 777") ;
_DelayMs(500);
Uart0PutS("Via express highway") ;
_DelayMs(500);
Uart0PutS("TIME:10:10A");
_DelayMs(500);
_DelayMs(500); //A lil delay
} // End While
} // End main
void _DelayMs(unsigned int count)
{
unsigned int j,k;
for (j=0;j<count;j++)
{
for (k=0;k<6000;k++)
{
__asm
{
nop;
nop;
}
}
}
}
void Uart0Init (void) // Initialize Serial Interface
{
PINSEL0 |= 0x00000005; //Enable RxD0 and TxD0
U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bit
U0DLL = 97; // 9600 Baud Rate @ 15MHz VPB Clock
U0LCR = 0x03; // DLAB = 0
}
void Uart0PutS(unsigned char *str) //A function to send a string on UART0
{
while(*str)
{
Uart0PutCh(*str++);
}
}
void Uart0PutCh (unsigned char ch) // Write character to Serial Port
{
while (!(U0LSR & 0x20));
U0THR = ch;
}
unsigned char Uart0GetCh (void) // Read character from Serial Port
{
while (!(U0LSR & 0x01));
return (U0RBR);
}
void ClcdInit(void)
{
IODIR0 |= (unsigned long)(DATA_PORT); //initialize D4:D7 pins as output
IODIR0 |= ((unsigned long)(1)<<CTRL_RS); //initialize RS pins as output
IODIR0 |= ((unsigned long)(1)<<CTRL_EN); //initialize EN pins as output
_CLEAR_EN(); //clear EN
_CLEAR_RS(); //clear RS
_ClcdDelayMs(300);
ClcdSendByte(0X03,0); //Configure bus width as 8-bit
_ClcdDelayMs(50);
ClcdSendByte(0X02,0); //Configure bus width as 4-bit, 1 line,5X7 dots
_ClcdDelayMs(50);
ClcdSendByte(0X28,0); //Configure bus width as 4-bit, 2 line,5X7 dots
_ClcdDelayMs(50);
ClcdSendByte(0X10,0); //Cursor move and Shift to left
_ClcdDelayMs(1);
ClcdSendByte(0x0D,0); // DisplayOn,CursorOff
_ClcdDelayMs(1);
ClcdSendByte(0x06,0); // EntryMode,Automatic Increment - No Display shift.
_ClcdDelayMs(1);
ClcdSendByte(0x01,0); //Clear Display and set address DDRAM with 0X00
_ClcdDelayMs(5);
}
void ClcdSendByte(unsigned char byte,unsigned char type)
{
_CLEAR_EN();
if(type==_TYPE_DATA)
{
_SET_RS(); // Selects data Register for read / write
}
else if(type==_TYPE_CMD)
{
_CLEAR_RS(); // Selects cmd Register for write
}
_ClcdDelay45Us();
IOCLR0 |= DATA_PORT; //Clear Data Port
IOSET0 |= ((((unsigned long)byte >> 4) & 0x0F)<<D4);//Send byte to Data port
_EnToggle();
_ClcdDelay45Us();
IOCLR0 |= DATA_PORT; //Clear Data Port
IOSET0 |= (((unsigned long)byte & 0x0F)<<D4); //Send byte to Data port
_EnToggle();
_ClcdDelay45Us();
}
void ClcdPutS_P( char *str)
{
while(*str) //Check for valid character
{
ClcdSendByte(*str++,_TYPE_DATA);//Send out the current byte pointed to
}
}
Raspberry Training
void ClcdGoto(unsigned char x,unsigned char y)
{
switch(y)
{
case 1:
// position for line 1
y=0x80 ;
break;
case 2:
// position for line 2
y=0xC0 ;
break;
default:
break;
}
ClcdSendByte((x-1+y),_TYPE_CMD);
}
void _ClcdDelayMs(unsigned int count)
{
volatile unsigned int j,k;
for (j=0;j<count;j++)
{
for (k=0;k<400;k++)
{
__asm
{
nop;
nop;
}
}
void _ClcdDelay45Us(void)
{
volatile unsigned int k;
for(k=0;k<409;k++)
{
__asm
{
nop;
}
}
}
No comments:
Post a Comment