Hi Paul,
Thanks for the assistance. Unfortunately, no joy yet. The code I wrote is below. I did change a few of the commands, as I have a 2x16 display, and the code on the US2066 directory I think is for a 4-line display. Also, I am using 5V digital logic, so I changed that command. I think all else is the same. The SPI is definitely sending least significant bit first, and the /CS line is going low before the data is transmitted. I am using a board with 2n7000-based level shifters for clock, SDI, and /CS. /RES is tied to +5V.
I also tried the initialization code at a much lower baud rate, without success.
The following pins are tied to +5V:
2,3,16
The following lines are tied to 0V:
1,4,5,6,10,11,12,13,14,17,18,19,20
The following pins are connected to the SPI port on the Atmel processor, first passing through a level-shifter board
7 - SPI clock
8 - SPI data out from
9 - Floating
15 - /CS
Code follows:
display_command:
push temp ; save command
cbi VPORT2_OUT, oled_enable ; clear the bit so the display will listen
ldi temp, $1f ; LSB transmits first, so reverse command preamble byte
rcall sout ; output the command preamble
pop temp ; retrieve command
mov r17, temp ; save a copy
; command byte needs to be transmitted as
; D0 D1 D2 D3 0 0 0 0
; D4 D5 D6 D7 0 0 0 0
; the SPI UART is already configured to transmit
; LSB first, so all we need to do is to mask off
; the D0-D3, transmit, then shift left D4-D7 to
; D0-D3 and transmit.
andi temp, $0F
rcall sout
mov temp, r17 ; get the original byte back
swap temp ; swap nibbles
andi temp, $0F
rcall sout
sbi VPORT2_OUT, oled_enable ; set bit so display will go deaf
ret
display_data:
push temp ; save data
cbi VPORT2_OUT, oled_enable ; clear the bit so the display will listen
ldi temp, $5f ; LSB transmits first, so reverse data preamble byte
rcall sout ; output the command preamble
pop temp ; retrieve data
mov r17, temp ; save a copy
; data byte needs to be transmitted as
; D0 D1 D2 D3 0 0 0 0
; D4 D5 D6 D7 0 0 0 0
; the SPI UART is already configured to transmit
; LSB first, so all we need to do is to mask off
; the D0-D3, transmit, then shirt left D4-D7 to
; D0-D3 and transmit.
andi temp, $0F
rcall sout
mov temp, r17 ; get the original byte back
swap temp
andi temp, $0F
rcall sout
sbi VPORT2_OUT, oled_enable ; set bit so display will go deaf
ret
init_display:
ldi temp, $2A ; //function set (extended command set)
rcall display_command
ldi temp, $71; //function selection A
rcall display_command
ldi temp, $5c; // (0x5C) = enable regulator (5V I/O)
rcall display_data
ldi temp, $28; //function set (fundamental command set)
rcall display_command
ldi temp, $08; //display off, cursor off, blink off
rcall display_command
ldi temp, $2A; //function set (extended command set)
rcall display_command
ldi temp, $79; //OLED command set enabled
rcall display_command
ldi temp, $D5; //set display clock divide ratio/oscillator frequency
rcall display_command
ldi temp, $70; //set display clock divide ratio/oscillator frequency
rcall display_command
ldi temp, $78; //OLED command set disabled
rcall display_command
ldi temp, $08; //extended function set (2-lines)
rcall display_command
ldi temp, $06; //COM SEG direction
rcall display_command
ldi temp, $72; //function selection B
rcall display_command
ldi temp, $00; //ROM CGRAM selection
rcall display_data
ldi temp, $2A; //function set (extended command set)
rcall display_command
ldi temp, $79; //OLED command set enabled
rcall display_command
ldi temp, $DA; //set SEG pins hardware configuration
rcall display_command
ldi temp, $10; //set SEG pins hardware configuration
rcall display_command
ldi temp, $DC; //function selection C
rcall display_command
ldi temp, $10; //function selection C
rcall display_command
ldi temp, $81; //set contrast control
rcall display_command
ldi temp, $7F; //set contrast control
rcall display_command
ldi temp, $D9; //set phase length
rcall display_command
ldi temp, $F1; //set phase length
rcall display_command
ldi temp, $DB; //set VCOMH deselect level
rcall display_command
ldi temp, $40; //set VCOMH deselect level
rcall display_command
ldi temp, $78; //OLED command set disabled
rcall display_command
ldi temp, $28; //function set (fundamental command set)
rcall display_command
ldi temp, $01; //clear display
rcall display_command
ldi temp, $80; // SET dram ADDRESS TO 0X00
rcall display_command
ldi temp, $0F; //display ON
rcall display_command
ldi temp, $01
rcall display_command
ldi temp, $45
rcall display_data
ret
;
Would you please check the initialization code and let me know if this looks OK? Again, your assistance is greatly appreciated. This is the last build step for my new receiver.
Regards,
Fred