LCDInfo.com http://forum.lcdinfo.com/ |
|
Read problems from T6963C controller http://forum.lcdinfo.com/viewtopic.php?f=9&t=1403 |
Page 1 of 1 |
Author: | Toverstaf [ Thu Nov 03, 2005 14:36 ] |
Post subject: | Read problems from T6963C controller |
I'm trying to read the data back from the display to a Atmel microcontroller. A device drives the display, then I want to disconnect the connection between device and display, and after all I want to read out all the pixels from the display. The hardware I made is ok and tested. The code below is not ok, it always returns B1h to Hyperterminal instead of the display data. I don't know what I'm doing wrong ! Could somebody help me with this problem? Code: // Includes
//======================================================================================== #include <mega163.h> #include <stdio.h> #include <delay.h> void start (void); void stop (void); void strobe (void); void command_w (void); void data_w (void); void data_r (void); unsigned char statusreturn (void); void statuscheck (void); int i; unsigned char ucData; unsigned char ucStatus1; unsigned char ucStatus2; // Defenities //======================================================================================== #define CELO PORTC.4 = 0 #define CEHI PORTC.4 = 1 #define WRLO PORTC.3 = 0 #define WRHI PORTC.3 = 1 #define RDLO PORTC.5 = 0 #define RDHI PORTC.5 = 1 #define CDLO PORTC.7 = 0 #define CDHI PORTC.7 = 1 // Functies //======================================================================================== void start (void) { // Control lijnen voor display configureren PORTC = 0x07; PORTC.3 = PIND.5; PORTC.4 = PIND.3; PORTC.5 = PIND.4; PORTC.6 = PINC.2; PORTC.7 = PIND.2; // Uitgang display = ingang computer PORTA = PINB; // Func0=Out Func1=Out Func2=Out Func3=Out Func4=Out Func5=Out Func6=Out Func7=Out // State0=0 State1=0 State2=0 State3=0 State4=0 State5=0 State6=0 State7=0 DDRA=0xFF; // Func0=In Func1=In Func2=In Func3=Out Func4=Out Func5=Out Func6=Out Func7=Out // State0=P State1=P State2=P State3=0 State4=0 State5=0 State6=0 State7=0 DDRC=0xF8; // Schakelaar onderbreken PORTD.7 = 1; } //======================================================================================== void stop (void) { // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=P PORTA=0xFF; DDRA=0x00; // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=P PORTC=0xFF; DDRC=0x00; // Schakelaar verbinden PORTD.7 = 0; } //======================================================================================== void strobe (void) { CELO; #asm nop nop nop nop nop #endasm CEHI; } //======================================================================================== void command_w (void) { CDHI; WRLO; RDHI; statuscheck(); strobe(); } //======================================================================================== void data_r (void) { CDLO; RDLO; WRHI; } //======================================================================================== void data_w (void) { CDLO ; CDLO; WRLO ; RDHI ; statuscheck(); strobe(); } //======================================================================================== unsigned char statusreturn (void) { unsigned char ucStatus; // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=P DDRA=0x00; CDHI ; RDLO ; WRHI ; CELO ; delay_us(10); ucStatus = PINA; CEHI ; DDRA = 0xFF; return (ucStatus); } //======================================================================================== void statuscheck (void) { unsigned char ucStatus1; unsigned char ucStatus2; // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=P DDRA=0x00; CDHI ; RDLO ; WRHI ; // Wait while STA0 & STA1 == 1 do { CELO ; #asm nop nop #endasm ucStatus1 = PINA; CEHI ; ucStatus2 = ucStatus1 & 0x03; } while (ucStatus2 != 0x03); DDRA = 0xFF; } //======================================================================================== void main(void) { // Port A initialisatie // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=P PORTA=0xFF; DDRA=0x00; // Port B initialisatie // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=P PORTB=0xFF; DDRB=0x00; // Port C initialisatie // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In // State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=P PORTC=0xFF; DDRC=0x00; // Port D initialisatie // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=Out // State0=P State1=P State2=P State3=P State4=P State5=P State6=P State7=0 PORTD=0x7F; DDRD=0x80; // UART initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // UART Receiver: On // UART Transmitter: On // UART Baud rate: 9600 UCSRA=0x00; UCSRB=0x18; UBRR=0x33; UBRRHI=0x00; delay_ms(10000); start(); PORTA = 0x00; // Set pointer to 0000h data_w(); PORTA = 0x00; data_w(); PORTA = 0x24; command_w(); PORTA = 0xb1; // Set display in AUTOMODE command_w(); for (i = 0; i<10000; i++) { do { ucStatus1 = statusreturn(); ucStatus2 = ucStatus1 & 0x08; } while (ucStatus2 != 0x08); DDRA = 0x00; ucData = PINA; printf("%c", ucData); // Send data to terminal DDRA = 0xff; } PORTA = 0xb2; // Bring LCD back to normal operation command_w(); stop(); while (1) { }; } //======================================================================================== |
Page 1 of 1 | All times are UTC + 2 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |