Code:
;7x5 led array witk ht16k33 mapped col 0-5 a0 - a6;highbyte of ROW[x] maps to a0:7 i2cread/write natively sends high byte first.
;chip actually wants data lowbyte first ~! typical
;pic12f1822
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _MCLRE_ON & _CP_OFF & _CPD_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG
OSCCON = %01110000
DEFINE OSC 8
TRISA = %001011
ANSELA = 0 'Digital
' DEFINE DEBUG_REG PORTA
' DEFINE DEBUG_BIT 0 ; if not used for pwr
' DEFINE DEBUG_BAUD 9600
' DEFINE DEBUG_MODE 0
' pause 2000
' Debug "Start",13 ,10
' DISPLAY ON 0X21
' NO BLINK 0X81
' ROW/INT 0XA0
' BRIGHT 0XEX
scl var portA.4
sda var portA.5
Led var LATA.2
SADD VAR BYTE
ROW VAR WORD[5]
COL var byte
TMP VAR WORD
CLEAR
INIT:
i2cwrite sda,scl,$E0,[$21] 'on
i2cwrite sda,scl,$E0,[$81] 'blink off
i2cwrite sda,scl,$E0,[$E8] 'HALF BRIGHT
i2cwrite sda,scl,$E0,[$A0] 'NO INT
i2cwrite sda,scl,$E0,[SADD,ROW,ROW,ROW,ROW,ROW] ;CLEAR
Main:
COL=35
while col ;walk a led backwards through array
col=col-1
TMP=0
TMP.0[14-(COL/5)]=1
SADD = 5
WHILE SADD
SADD=SADD-1
ROW[SADD]=0
WEND
ROW[(COL//5)]=TMP
i2cwrite sda,scl,$E0,[SADD,ROW[0],ROW[1],ROW[2],ROW[3],ROW[4]]
pause 100
wend
SADD = 0
FOR ROW=0 TO 127
ROW=ROW<<8
i2cwrite sda,scl,$E0,[SADD,ROW,~ROW,ROW,~ROW,ROW]
pause 50
ROW=ROW>>8
NEXT
FOR COL=0 TO 34
TMP=0
' SADD=COL//5
TMP.0[14-(COL/5)]=1
' Debug 13,10,#COL,9,HEX TMP,9,#SADD
SADD = 5
WHILE SADD
SADD=SADD-1
ROW[SADD]=0
WEND
ROW[(COL//5)]=TMP
i2cwrite sda,scl,$E0,[SADD,ROW[0],ROW[1],ROW[2],ROW[3],ROW[4]]
pause 100
NEXT
LED=!LED
pause 500
goto main
end
Bookmarks