Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 4th May 2007, 05:47 AM   #1
Default OLED LCD Code Problems

Hello,

I am writing some assembly to control a LCD with a SSD1339 controller with a 8bit 6800 parallel interface. The timing diagram for the communication is here on page 56.
(Datasheet: http://www.sparkfun.com/datasheets/LCD/SSD1339_1.7.pdf)

I have looked through the datasheet and it looks pretty straight forward, but I can't seem to get the LCD to turn on. Early in the datasheet it said that it uses the Enable pin as a latch for the data, but the timing suggests that it is CS# instead? Here are the essential elements for the LCD that I have written:
Code:
LCD_C MACRO X
	MOVLW X
	CALL LCD_WriteCommand
	ENDM
LCD_D MACRO X
	MOVLW X
	CALL LCD_WriteData
	ENDM
LCD_WriteData
	BSF	port_lcdctrl,lcd_DC
	CALL LCD_WriteByte
	RETURN
LCD_WriteCommand
	BCF	port_lcdctrl,lcd_DC
	CALL LCD_WriteByte
	RETURN
LCD_WriteByte

	;This is a mess... I hooked up the D7 to D0 (mcu) backwards to the LCD
	;hence I have to reverse the order of the byte. 
	;TODO: THINK OF A MORE EFFICIENT WAY OF DOING THIS!
	MOVWF lcd_buffer

	CLRF 	lcd_buffer1
	
	BTFSC   lcd_buffer, 0
	BSF     lcd_buffer1, 7
	BTFSC   lcd_buffer, 1
	BSF     lcd_buffer1, 6
	BTFSC   lcd_buffer, 2
	BSF     lcd_buffer1, 5
	BTFSC   lcd_buffer, 3
	BSF     lcd_buffer1, 4
	BTFSC   lcd_buffer, 4
	BSF     lcd_buffer1, 3
	BTFSC   lcd_buffer, 5
	BSF     lcd_buffer1, 2
	BTFSC   lcd_buffer, 6
	BSF     lcd_buffer1, 1
	BTFSC   lcd_buffer, 7
	BSF     lcd_buffer1, 0
	
	;make sure reset is high (not resetting). I have heard that some
	;people have troubles with pins randomly falling low.
	BSF port_lcdctrl, lcd_RES

	; Move Byte onto portD
 	MOVF 	lcd_buffer1, w
 	MOVWF	port_lcddata
	
	BSF 	port_lcdctrl, lcd_E
 	BCF 	port_lcdctrl,lcd_Rw

	BCF 	port_lcdctrl, lcd_CS

	CALL 	DLYMS
	
	BSF 	port_lcdctrl, lcd_CS
	
	CALL 	DLYMS

	BCF 	port_lcdctrl,lcd_E
	BSF 	port_lcdctrl,lcd_Rw
	BSF 	port_lcdctrl,lcd_DC
	
	RETURN
LCD_Init
	
		CLRF port_lcddata
	BSF port_lcdctrl, lcd_E
	BCF port_lcdctrl, lcd_DC
	BCF port_lcdctrl,lcd_Rw

  	CALL LCD_Reset
	
	LCD_C h'A0'
	LCD_D b'01100000' ;Configure color settings
	
	LCD_C h'A1'
	LCD_D 00h ;Set display start line
	
	LCD_C h'A2'
	LCD_D 0 ;Set offset
	
	LCD_C h'A6';Set to normal display
	
	LCD_C h'AD'
	LCD_D h'8E' ;Set VCOMH source
	
	LCD_C h'B0'
	LCD_D b'00000101' 
	
	 ; // Set pre & dis_charge
  	; // pre=1h dis=1h
  	LCD_C h'B1'
	LCD_D h'11' 
	
 ; // clock & frequency
  ; // clock=Divser+1 frequency=fh
  	LCD_C h'B3'
	LCD_D h'F0' 
	
 ; // Set pre-charge voltage of color A B C
  ; // color A
  ; // color B
  ; // color C
 	LCD_C h'BB'
	LCD_D h'1C'
	LCD_D h'1C' 
	LCD_D h'1C'
	
  ; // Set VcomH
  ; //
  	LCD_C h'BE'
	LCD_D h'1F'
	
  ; // Set contrast current for A B C
  ; // Color A
  ; // Color B
  ; // Color C
 	LCD_C h'C1'
	LCD_D h'AA' 
	LCD_D h'B4' 
	LCD_D h'C8' 
	
  ; // Set master contrast
  ; // no change
  	LCD_C h'C7'
	LCD_D h'0F' 
	
  ; // Duty
  ; // 127+1
  	LCD_C h'CA'
	LCD_D h'7F'
	
 ; // Display on
	LCD_C h'AF'
	
	RETURN
I'm quite sure that I have the hardware end hooked up correctly and it is something slightly wrong with my code. My guess is that it is either the way I am setting the control pins for writing to the LCD or the initialization parameters. I would be deeply grateful if anyone could lend some expertise!

Edit: There isn't anyway to remap a port in MPLAB is there? That would be a nice software feature to have (to take literals and rearrange them).

Last edited by freeskier89; 4th May 2007 at 08:10 AM.
freeskier89 is offline  
Reply

Tags
code, lcd, oled, problems

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Adapting LCD code for 16F876 bh00 Micro Controllers 12 22nd February 2007 04:03 PM
Tough assembly program for the PIC16F84 asmpic Micro Controllers 34 3rd December 2004 07:50 PM
Work ID reader Track 2 problems with pic code. Need help! egg0900 Micro Controllers 2 19th April 2004 07:58 AM
An error in pic16f84a, why? Zener_Diode Micro Controllers 6 11th April 2004 03:55 AM
12C508 problems: Verify failed at code address 0000h ! faz666 Micro Controllers 4 29th July 2003 01:13 PM



All times are GMT. The time now is 01:44 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker