Forum: Mikrocontroller und Digitale Elektronik Allgemeine Frage zur Ansteuerung eines grafischen LCD's


von Daniel Ried. (DrD) (Gast)


Lesenswert?

Hallo,
ich habe mal ein paar Fragen bezüglich der Ansteuerung eines grafischen
LCD's.

Mein Display: DEM 128064A SYH-LY
Datenblatt: http://www.display-elektronik.de/DEM128064ASYH-LY.PDF

Display-Controller: S6B0107
Datenblatt:
http://pdf1.alldatasheet.com/datasheet-pdf/view/37853/SAMSUNG/S6B0107.html

µC: Mega16
Compiler: CodeVisionAVR

- Ist die Ansteuerung des Display's OK? Welche
Verbesserungsmöglichkeiten gibt es?
- Die Busy-Flag Abfrage funktioniert nicht. An welcher Stelle muss ich
die Abfrage machen? Ich habe Probleme mit dem Timing.
In outAdrr1 wird kein Delay benötigt, aber in outAddr2 muss eins sein.
Warum? Dabei ist mein Delay keins, bis auf einen Sprung in eine
Funktion. Vorher hatte ich einen Software-Timer, aber da war der
Bilaufbau dermaßen langsam, dass ich ausprobiert habe, ob es auch ohne
funktioniert. Dann habe ich 7 NOP's benutzt und jetzt funktioniert es
auch komplett ohne.
Wie funktioniert eine timerunabhängige Steuerung, nur per Busy-Flag?


Hier sind meine Routinen:

void delay(uint msec){      // bei 8MHz
uchar i=0;
/*
  start_sw_timer(1,msec);
  while (get_sw_timer(1)!=0){
  };
*/
/*
for (i=0;i<1;i++){      // vorher Grenze 6
  #asm("nop");
}
*/
}

// read Busy Flag; 1 ready, 0: busy
unsigned char readBusyFlag(void){
uchar temp=0;
 DATA_PORT=0x00;               //set PORTB all bits output
 RS=H; RW=H; EN=H; CS1=L; CS2=H; RST=H;    //Bits setzen
 RS=L; RW=1;EN=H;        // Status Read
 delay(0);
 if ((LCD_DATAR&0x80)==0) temp=1; else temp=0;
 RS=H; RW=H; EN=L; CS1=L; CS2=H; RST=H;
 TOGGLE=temp;
 return temp;
}


// write an instruction/address to controller-2
void outAdr2(unsigned char address)
{
 DATA_PORT=0xFF;              //set PORTB all bits output
 LCD_DATAW=address;        // write output data to PortB
 //delay(0);        // 10ms Pause

 // write to controller-2
 RS=L; RW=L; EN=H; CS1=L; CS2=H; RST=H;
 delay(0);        // 10ms Pause
 RS=L; RW=L; EN=L; CS1=L; CS2=H; RST=H;
 //delay(0);        // 10ms Pause

 DATA_PORT=0x0;            //set PORTB all bits input
}  // outAdr2()

// write an instruction/address to controller-1
void outAdr1(unsigned char address)
{
 DATA_PORT=0xFF;                   //set PORTB all bits output

 LCD_DATAW=address;        // write output data to PortB
 //delay(0);        // 10ms Pause

 // write to controller-1
 RS=L; RW=L; EN=H; CS1=H; CS2=L; RST=H;
 //delay(0);        // 10ms Pause
 RS=L; RW=L; EN=L; CS1=H; CS2=L; RST=H;  // doppelt
 //delay(0);        // 10ms Pause

 DATA_PORT=0x0;          //set PORTB all bits input
}  // outAdr1()

//write display-data to controller-1
void outData1( unsigned char dta)
{
 DATA_PORT=0xFF;             //set PORTB all bits output

 LCD_DATAW=dta;           // write output data to port
 //delay(0);        // 10ms Pause

 RS=H; RW=H; EN=H; CS1=H; CS2=L; RST=H;
 delay(0);        // 10ms Pause

 // write to controller-1
 RS=H; RW=L; EN=H; CS1=H; CS2=L; RST=H;
 //delay(0);        // 10ms Pause
 RS=H; RW=L; EN=L; CS1=H; CS2=L; RST=H;
 delay(0);        // 10ms Pause
 RS=H; RW=H; EN=L; CS1=H; CS2=L; RST=H;
 //delay(0);        // 10ms Pause

 DATA_PORT=0x0;            //set PORTB all bits input
}  //of outData1()

//write display-data to controller-2
void outData2( unsigned char dta)
{
 DATA_PORT=0xFF;            //set PORTB all bits output
 //delay(0);        // 10ms Pause
 LCD_DATAW=dta;           // write output data to port
 //delay(0);                            // 10ms Pause
 RS=H; RW=H; EN=H; CS1=L; CS2=H; RST=H;
 delay(0);                               // 10ms Pause

 // write to controller-1
 RS=H; RW=L; EN=H; CS1=L; CS2=H; RST=H;
 //delay(0);                            // 10ms Pause
 RS=H; RW=L; EN=L; CS1=L; CS2=H; RST=H;
 delay(0);                               // 10ms Pause

 RS=H; RW=H; EN=L; CS1=L; CS2=H; RST=H;
 //delay(0);                            // 10ms Pause

 DATA_PORT=0x0;        //set PORTB all bits input
}



// liest ein BMP-Array ein und gibt es auf dem Dispaly aus
//(Sinuskurve)
void sinusZ(unsigned char xLoc, unsigned char yLoc)
{
 unsigned char twoWidth;
 unsigned char twoHeight;
 unsigned char yOffset=0x00;
 unsigned char xOffset=0x00;
 uint i=0;

 twoWidth=yLoc+0x80;
 twoHeight=xLoc+0x08;

for(xOffset=xLoc; xOffset<twoHeight; xOffset++){
 for(yOffset=yLoc;yOffset<0x80; yOffset++)
 {
   if (yOffset < 0x40){
  outAdr1(yOffset+0x40);
  while(readBusyFlag&0x80==0){};
  outAdr1(xOffset);
  while(readBusyFlag&0x80==0){};
  outData1(sinus[i]);
  i++;
   }
   else{
  outAdr2(yOffset);
  while(readBusyFlag&0x80==0){};
  outAdr2(xOffset);
  while(readBusyFlag&0x80==0){};
  outData2(sinus[i]);
  i++;
   }
 }

}
}


Würde mich über alle Antworten freuen, da ich schon ziemlich lange
daran sitze ;-)
Mfg Daniel

von Bernhard S. (bernhard)


Lesenswert?

Hallo Daniel,

> Die Busy-Flag Abfrage funktioniert nicht.

Ist aber sehr wichtig bei Grafischen LCDs, ansonsten dauert der
Bildaufbau zu lange, da man nach jedem Befehl eine lange Wartezeit
implementieren müsste.

Sind die internen Pull-Ups auch ausgeschaltet, da das Display relativ
hochohmig die Daten an den µC sendet?

Wird Busy permanent durch ein Enable-Impuls abgefragt?

>An welcher Stelle muss ich die Abfrage machen?

Am günstigsten, befor ein neuer Befehl an das LCD gesendet wird.


>Wie funktioniert eine timerunabhängige Steuerung, nur per Busy-Flag?

ja, neue LCD-Daten warten so lange, bis Busy es zulässt, erst dann
startet die Datenübertragung an das LCD.


Bernhard

von Daniel Ried. (DrD) (Gast)


Lesenswert?

Hallo,
also es scheint jetzt zu funktionieren.
Ich habe keine Delay-Schleifen mehr drin und es läuft mit 16 Mhz.
Hatte noch ein paar Fehler in den Port-Registern und die Pull-Up's hab
ich auch ausgeschaltet.
Danke erstmal

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.