Chyba v Procyon AVRlib, subor LCD.C

Richard Kaliciak hw.kaliciak@stonline.sk
Čtvrtek Březen 30 09:50:14 CEST 2006


Dobry den,

chcem vas upozornit na chybu v subore LCD.C z kniznice Procyon AVRlib.
Pre 4-bitovy rezim nefunguje citanie Busy-bitu, chyba tam jeden E-impulz
na konci. Povodny text (skratene):
---------- zaciatok ----------
void lcdBusyWait(void)
...
  while(inb(LCD_DATA_PIN) & 1<<LCD_BUSY)
  {
    cbi(LCD_CTRL_PORT, LCD_CTRL_E);   // clear "E" line
    LCD_DELAY;  // wait
    LCD_DELAY;  // wait
    sbi(LCD_CTRL_PORT, LCD_CTRL_E);   // set "E" line
    LCD_DELAY;  // wait
    LCD_DELAY;  // wait
    #ifdef LCD_DATA_4BIT            // do an extra clock for 4 bit reads
      cbi(LCD_CTRL_PORT, LCD_CTRL_E); // clear "E" line
      LCD_DELAY;  // wait
      LCD_DELAY;  // wait
      sbi(LCD_CTRL_PORT, LCD_CTRL_E); // set "E" line
      LCD_DELAY;  // wait
      LCD_DELAY;  // wait
    #endif
  }
  cbi(LCD_CTRL_PORT, LCD_CTRL_E);     // clear "E" line
  //  leave data lines in input mode so they can be most easily used for
other purposes
...
---------- koniec ----------

za koniec slucky treba doplnit jeden E impulz:
---------- zaciatok ----------
void lcdBusyWait(void)
...
  while(inb(LCD_DATA_PIN) & 1<<LCD_BUSY)
  {
    cbi(LCD_CTRL_PORT, LCD_CTRL_E);   // clear "E" line
    LCD_DELAY;  // wait
    LCD_DELAY;  // wait
    sbi(LCD_CTRL_PORT, LCD_CTRL_E);   // set "E" line
    LCD_DELAY;  // wait
    LCD_DELAY;  // wait
    #ifdef LCD_DATA_4BIT            // do an extra clock for 4 bit reads
      cbi(LCD_CTRL_PORT, LCD_CTRL_E); // clear "E" line
      LCD_DELAY;  // wait
      LCD_DELAY;  // wait
      sbi(LCD_CTRL_PORT, LCD_CTRL_E); // set "E" line
      LCD_DELAY;  // wait
      LCD_DELAY;  // wait
    #endif
  }
  #ifdef LCD_DATA_4BIT            // do an extra clock for 4 bit reads
    cbi(LCD_CTRL_PORT, LCD_CTRL_E); // clear "E" line
    LCD_DELAY;  // wait
    LCD_DELAY;  // wait
    sbi(LCD_CTRL_PORT, LCD_CTRL_E); // set "E" line
    LCD_DELAY;  // wait
    LCD_DELAY;  // wait
  #endif
  cbi(LCD_CTRL_PORT, LCD_CTRL_E);     // clear "E" line
  //  leave data lines in input mode so they can be most easily used for
other purposes
...
---------- koniec ----------

Problem sa prejavil po zapise osmeho znaku na dislpej. Pri citani z
displeja sa vyhodnocovala DDRAM adresa ako nastaveny busy.

Dalsi problem je pri inicializovani displeja do 4-bitoveho rezimu. Po
zapnuti napajania je standardne v 8-bitovom rezime. Pri inicializacii do
4-bitoveho rezimu sa sice prepne, ale spodna polovica byte sa ignoruje
(piny niesu zapojene). Displej funguje iba ako jedoriadkovy. Preto treba
zopakovat inicializaciu.

Povodny text (skratene):
---------- zaciatok ----------
void lcdInit()
...
  // LCD function set
  lcdControlWrite(LCD_FUNCTION_DEFAULT);
  delay(40000);
  // clear LCD
...
---------- koniec ----------

oprava:
---------- zaciatok ----------
void lcdInit()
...
  // LCD function set
  lcdControlWrite(LCD_FUNCTION_DEFAULT);
  delay(40000);
  #ifdef LCD_DATA_4BIT
    lcdControlWrite(LCD_FUNCTION_DEFAULT);
    delay(40000);
  #endif
  // clear LCD
...
---------- koniec ----------

Okrem toho odporucam pred prepnutim do 4-bitoveho rezimu poslat dvakrat
inicializaciu 8-bitoveho rezimu, aby sa displej zasynchronizoval na
parny pocet E impulzov.

Myslim si, ze autor pouzival iba 8 bitovu komunikaciu.
Povodna kniznica je dostupna na adrese
http://hubbard.engr.scu.edu/embedded/avr/avrlib/

Richard Kaliciak


________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Server.
http://www.nod32.com



Další informace o konferenci Hw-list