Hello, Sherbrook.
I made change below but yet not works. I will buy another display, I thing this display is wrong, but I don't have sure.
'************************************************* ***************
'* Name : LKM1638.BAS *
'* Author : Sherbrook' *
'* Notice : Microcode loader and PicBasic assembler. *
'* : All Rights Reserved *
'* Date : 24/7/2013 *
'* Version : v 2.0 *
'* Notes : *
'* : *
'************************************************* ***************
'@ DEVICE PIC16F873A, XT_OSC 'Xtal OSC
'@ DEVICE PIC16F873A, WDT_OFF 'WDT off
'@ DEVICE PIC16F873A, PWRT_ON 'Power-up timer on
'@ DEVICE PIC16F873A, BOD_OFF 'Brown-out detect off
CLEAR ; start with clearing the
DEFINE OSC 48
Define RESET_ORG 800h
'strobe var PORTA.4
sda VAR PORTB.1
scl VAR PORTB.0
TRISA=%11111111 ' Configura o PortA como Entrada
TRISB=%00000000 ' Configura o PortB como Saida
TRISC=%00000000 ' Configura o PortC como Saida
INTCON2.7 = 1 ' Turn Pull Up Resitor (PORTB Only) 0=Enable/1=Desable
ADCON1 = %00001111 ' Sets all ports to digital
PORTA = %00000000 ' Turn off all PortA
PORTB = %00000000 ' Turn off all PortB
PORTC = %00000000 ' Turn off all PortC
'================================================= =======
'TRISC = %00000000
'TRISB = %00000001 ' LCD display / I/R input
'TRISA = %11000000 ' A.6 & A.7 Bootloader
'ADCON1 = %00000110 ' PortA all digital
fix_addr con $C0 ' Start address of 7 segs & LEDs '($C0 = %11000000 = address $00)
auto_addr con $40 ' Address of auto-increment mode (Change to $44-IC1640)
'read_mode con $42 ' Address to read switches
char var byte ' LOOKUP offset for 7 seg code
disp_addr var byte ' Offset from display start address (ODD = LED, EVEN = 7seg)
data_io var byte ' Data IN / OUT
disp_brit var byte ' Display brightness
seg_val var byte ' Code to send to 7 seg displays LEDs 0 = OFF, 1 = RED, 2 = GREEN
bank var byte ' 0 = Left 7 segment, 2 = next segment ...... 14 = Right 7 segment
'sw1 var byte ' Byte 1 of switch read
'sw2 var byte ' Byte 2 of switch read
'sw3 var byte ' Byte 3 of switch read
'sw4 var byte ' Byte 4 of switch read
'switch var byte ' Switch pressed as binary number
counter var byte ' General counter
counter1 var byte
'strobe = 1 ' Set strobe pin high
SDA = 1 ' Set data pin high
SCL = 1 ' Set clock pin high
disp_brit = $88 ' Set minimum brightness (Max = $8F)
bank = 0
DISP_ADDR = 0
'----------------------------------------------------------------
gosub clear_char: 'Clear 7 seg displays & LEDs
gosub display: 'Write Chars to 7 seg display
MAIN:
for DISP_ADDR = 1 to 15 step 2
gosub write_display 'Write to LEDs display
seg_val = seg_val + 1
if seg_val > 2 then seg_val = 0
next
for counter1 = 0 to 50 'Pause for 1 sec
pause 20
next
goto MAIN:
end
'----------------------------------------------------------------
DISPLAY:
gosub WRITE_MODE:
DISP_ADDR = bank + 0
char = 0 'Print "0"
gosub lookup_char:
gosub write_display:
DISP_ADDR = bank + 2
char = 1 'Print "1"
gosub lookup_char:
gosub write_display:
DISP_ADDR = bank + 4
char = 2 'Print "2"
gosub lookup_char:
gosub write_display:
DISP_ADDR = bank + 6
char = 3 'Print "3"
gosub lookup_char:
gosub write_display:
DISP_ADDR = bank + 8
char = 4 'Print "4"
gosub lookup_char:
gosub write_display:
DISP_ADDR = bank + 10
char = 5 'Print "5"
gosub lookup_char:
gosub write_display:
DISP_ADDR = bank + 12
char = 6 'Print "6"
gosub lookup_char:
gosub write_display:
DISP_ADDR = bank + 14
char = 7 'Print "7"
gosub lookup_char:
gosub write_display:
gosub display_brit: 'Set Display brightness
return
'----------------------------------------------------------------
CLEAR_CHAR: 'Clear LEDs & 7 seg displays
gosub write_mode:
'STROBE = 0
data_io = FIX_ADDR 'Set start address
gosub send_char:
for counter = 1 to 16
data_io = 0 'Blank display
gosub send_char:
next
'Strobe = 1
return
'----------------------------------------------------------------
CLEAR_LEDS: 'Clear LEDs only
gosub write_mode:
for DISP_ADDR = 1 to 15 step 2
SEG_VAL = 0 'Turns LEDs OFF
gosub write_display:
next
gosub display_brit 'Set brightness
return
'----------------------------------------------------------------
SEND_CHAR:
shiftout SDA,SCL,4,[data_io]'LSB first, CLOCK idle HIGH
return
'----------------------------------------------------------------
LOOKUP_CHAR:
' lookup char,[1,2,4,8,16,32,64,128],seg_val
' Turns on a different segment on each display
lookup char,[$3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F,$77,$7C,$5 8,$5E,$79,$71,$0],SEG_VAL
'Value for 0,1,2,3,4,5,6,7,8,9,A,b,c,d,E,F,(Blank)
return
'----------------------------------------------------------------
DISPLAY_BRIT:
data_io = disp_brit
'STROBE = 0
gosub send_char:
'STROBe = 1
return
'----------------------------------------------------------------
WRITE_DISPLAY:
data_io = FIX_ADDR + DISP_ADDR
'strobe = 0
gosub send_char:
data_io = SEG_VAL
gosub send_char:
'STROBE = 1
gosub display_brit:
return
'----------------------------------------------------------------
WRITE_MODE:
DATA_IO = AUTO_ADDR
'strobe = 0
gosub send_char:
'strobe = 1
return
'================================================= ================
Thank you for your attention.
Bookmarks