LCD hitachi hc9s12256Dp

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LCD hitachi hc9s12256Dp

1,234件の閲覧回数
nevi
Contributor I
hello, I have problem with program. I don't know what is cmd_reg. This program is from one book. But there wasn't explaint it.
#include hc12.h
#include stdio.h
char *msg = "this is a very very very long string in the desert storm";
void putc2lcd(char ch);
void puts2lcd(char *ptr);
void lcd_init();

void main(void)
{
lcd_init();
puts2lcd(msg);
asm("swi");
}
void lcd_init()
{
while(cmd_reg & 0x80); /* wait until LCD is ready */
cmd_reg = 0x3C; /* set 4 x 20 display */
while(cmd_reg & 0x80);
cmd_reg = 0x0f; /* display and cursor on */
while(cmd_reg & 0x80);
cmd_reg = 0x14; /* display and cursor on */
while(cmd_reg & 0x80);
cmd_reg = 0x01; /* display and cursor on */
while(cmd_reg & 0x80);
}
void puts2lcd (char *ptr)
{
while (*ptr) {
putc2lcd (*ptr);
ptr++;
}
} Do you know please. What should be cmd_reg? And how i can do that? Thank you very much. I sorry for my english.

Message Edited by nevi on 2008-03-29 11:29 PM

Message Edited by nevi on 2008-03-29 11:30 PM
ラベル(1)
0 件の賞賛
返信
2 返答(返信)

376件の閲覧回数
peg
Senior Contributor IV
Hello and welcome to the forums nevi,

This code looks like it is for a 4x20 character LCD module based on a Hitachi HD44780 controller.
Therefore cmd_reg would be the 8-bit port which connects to the data port of the LCD module.
They are using reads of the busy flag in between initialisation writes instead of delays and it is unclear how the  modules R/W input is being controlled.
Also you have not shown us the putc2lcd function.

It is a good idea to use a code box (the SRC button) to display example code as it will look neater.

0 件の賞賛
返信

376件の閲覧回数
JimDon
Senior Contributor III
I have some sample code, but it uses 4 bit mode.
Quite often interfaces do this so that only 6 bits are used.
There are 4 data bits, a command/data line, and a strobe. The R/W line is always set to write.
This controller can do 4-bit or 8-bit transfers.

Can you confirm the connection of your interface?
What board is it?

0 件の賞賛
返信