It’s me again
I found an example code (LCD2.C) for the BL-1800 jack rabbit board in
http://www.rabbitsemiconductor.com/support/downloads/downloads_prod.shtml
and I made some changes of my own to fit my board (coyote-2500)
Now at least characteres show up in the LCD, but they are meaningless, eg., if a I send an ‘a’ it prints ‘F’, if I send ’ ’ (space) it prints “||” and so on. And when sending control characteres (blank lcd, return home, etc), it seems to lost its way.
I’ve tried some configs and delays, but none of them make it works as it must.
Here it is the adapted code. Pinout is the same as above. Thanks in advanced
void fn4Clear(void);
/*********************************************************************
fnMsDelay - delay some number of milliseconds
input parameter: int number of milliseconds to delay
return value: none
errors: none
*/
void fnMsDelay ( int iDelay )
{ unsigned long ul0;
ul0 = MS_TIMER; // get current timer value
while ( MS_TIMER < ul0 + (unsigned long) iDelay );
}
/*********************************************************************
fnUsDelay - delay some number of micro seconds - very approximate!!
about 11usec per iteration with the 7.3MHz crystal. The formula
used here was determined experimentally.
*/
void fnUsDelay ( int iDelay )
{ int i;
iDelay /= 11;
for ( i=0; i>= 4; // put upper nibble into lower 4 bits
fn4OneNib ( cNib ); // send upper nibble
fn4OneNib ( i ); // send lower nibble
fnUsDelay (100);
}
/*********************************************************************
fn4LCD_Init - Initialize the LCD for the following operating parameters:
4 bit mode, 2 lines, 5x10
turn on display and cursor: non-blinking
incr address and shift cursor with each character
*/
void fn4LCD_Init ()
{
iDataFlag = COMMAND; // show command mode
fnMsDelay ( 500 ); // wait for LCD to reset itself
fn4OneNib ( 3 ); // 8 bit mode
fnMsDelay ( 10 );
fn4OneNib ( 3 ); // 8 bit mode
fnMsDelay ( 2 );
fn4OneNib ( 3 ); // 8 bit mode
fnMsDelay ( 2 );
fn4OneNib ( 2 ); // 4 bit mode
fnMsDelay (2);
fn4Byte ( 0x28 ); fnMsDelay ( 1 );
fn4Byte ( 0x0e ); fnMsDelay ( 1 );
fn4Byte ( 0x01 ); fnMsDelay ( 3 );
fn4Byte ( 0x42 ); fnMsDelay ( 1 );
/*
fn4Byte ( 0x2c ); fnMsDelay ( 1 );
fn4Byte ( 0x0e ); fnMsDelay ( 1 );
fn4Byte ( 0x01 ); fnMsDelay ( 3 );
fn4Byte ( 0x06 ); fnMsDelay ( 1 );
fn4Byte ( '\B00000010' ); fnMsDelay ( 3 );
*/
//fn4Byte ( '\B00000110' ); // incr address and shift cursor with each character
}
/*********************************************************************
fn4Display - display a line of text on the LCD
argument: address of null terminated text string
*/
void fn4Display ( char *szp )
{
char c;
//printf("%s
",szp);
iDataFlag = DATA; // next bytes are data
while ( *szp ){
c=*(szp++);
fn4Byte ( c );
fnMsDelay (3);
}
}
void fn4Clear ( void )
{ iDataFlag = COMMAND; // set up for command
fn4Byte ( 0x01 ); // clear the display
fnMsDelay (3); // insure at least 2 msec
}
void fn4Line2 ( void )
{ iDataFlag = COMMAND; // set up for command
//fn4Byte ( 0xC0 ); // set RAM address to Line 2
//note: this value may vary for different displays
fn4Byte ( 0x40 );
fnMsDelay (3); // insure at least 2 msec
}
const char cad[]=“abzdefghijklmnop”;
void main ()
{
brdInit();
fn4LCD_Init ();
while (1)
{
fn4Clear();
fn4Byte ( 0x02 ); fnMsDelay ( 3 );
//fn4Display ( "0123456789" );
fn4Display ( cad );
//fnMsDelay (500);
//fn4Clear();
fn4Byte ( 0x02 ); fnMsDelay ( 3 );
fn4Display ( "abcd" );
fnMsDelay (500);
}
}