Hallo zusammen. Ich versuche ein EADog LCD an einem PIC16F876a im SPI-Modus zu betreiben. Ich habe mir folgendes Programm ausgedacht, aber es tut sich nichts. Kann mir jemand sagen was ich falsch mache? #pragma config=0x3F31 bit RS@PORTA.0; bit CSB@PORTA.1; bit CLK@PORTA.2; bit SI@PORTA.3; void warten(unsigned long int ms){ char i; unsigned long int j; for(j=0;j<ms;j++) { for(i=0;i<120;i++)nop(); } } void Init(){ TRISA=0b.0000.0000; } void Function_Set1(){ char Bitmuster,i; Bitmuster=0b.0011.1000; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0;nop(); CLK=1;nop(); CLK=0;nop(); Bitmuster=Bitmuster<<1; } } void Function_Set2(){ char Bitmuster,i; Bitmuster=0b.0011.1001; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0;nop(); CLK=1;nop(); CLK=0;nop(); Bitmuster=Bitmuster<<1; } } void Bias_Set(){ char Bitmuster,i; Bitmuster=0b.0001.0100; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0;nop(); CLK=1;nop(); CLK=0;nop(); Bitmuster=Bitmuster<<1; } } void Contrast_Set(){ char Bitmuster,i; Bitmuster=0b.0111.1000; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0;nop(); CLK=1;nop(); CLK=0;nop(); Bitmuster=Bitmuster<<1; } } void Contrast_Control(){ char Bitmuster,i; Bitmuster=0b.0101.0010; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0;nop(); CLK=1;nop(); CLK=0;nop(); Bitmuster=Bitmuster<<1; } } void Follower_Control(){ char Bitmuster,i; Bitmuster=0b.0110.1001; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0;nop(); CLK=1;nop(); CLK=0;nop(); Bitmuster=Bitmuster<<1; } } void Display_Control(){ char Bitmuster,i; Bitmuster=0b.0000.1100; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0;nop(); CLK=1;nop(); CLK=0;nop(); Bitmuster=Bitmuster<<1; } } void Clear_Display(){ char Bitmuster,i; Bitmuster=0b.0000.0001; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0;nop(); CLK=1;nop(); CLK=0;nop(); Bitmuster=Bitmuster<<1; } } void Entrymode_Set(){ char Bitmuster,i; Bitmuster=0b.0000.0110; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0;nop(); CLK=1;nop(); CLK=0;nop(); Bitmuster=Bitmuster<<1; } } void test1(){ char Bitmuster, i; Bitmuster=0b.1000.0101; CSB=0; RS=0; for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0; CLK=1; CLK=0; Bitmuster=Bitmuster<<1; }//endfor } void test2(){ char Bitmuster, i; Bitmuster=0b.0100.0110; CSB=0; RS=1;nop(); for (i=8;i>0;i--){ if (Bitmuster.7==1)SI=1;else SI=0; CLK=1; CLK=0; Bitmuster=Bitmuster<<1; }//endfor } void Display_Init(){ warten(40); Function_Set1(); nop(); Function_Set2(); nop(); Bias_Set(); nop(); Contrast_Set(); nop(); Contrast_Control(); nop(); Follower_Control(); warten(200); Display_Control(); nop(); Clear_Display(); warten(2); Entrymode_Set(); nop(); } void main(){ Init(); CSB=1; CLK=0; SI=0; RS=0; Display_Init(); for(;;){ test1(); nop(); test2(); }//endfor }//endmain Vielen Dank für Eure Hilfe.
Hi Ist zwar für AVRs, aber sieh dir mal das Beispiel an: >http://www.lcd-module.de/deu/disk/development%20service/DOG%20Text%20ST7036/INIT_DOG_7036_AVRGCC.c MfG Spess
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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.