William At MyBlueRoom
New Member
I've posted a small code segment for my Cricket communicating thermostat. This should help understand how the charlieplexed display works.
look for the download link on Updates / March 2006
Bill
www.myblueroom.com
look for the download link on Updates / March 2006
Bill
www.myblueroom.com
Code:
;Cricket Display 1.0beta written using Tech-Tools assembler CVASM16.6x
;This code segment is for a PIC16F628A but other 14bit PICs should function
;Clarlieplexed display optimized for a 4 digit LED display split on RA0-3 & RB4-7
;Variables:
;Jiffy = byte incremented every 1/256 second and calls routine 64hz refresh per digit
;Display = Pointer to RAM; Segments to display via INDF 0xxxxxxx (1 = LED / Segment on)
;Temp_A = Bit Postion then I/O port direction, 0-3 port A, 4-7 port B
;
;---- Uncomment routine below, make sure it's in the same bank as DispRefresh
;BitMask jmp PC+W
; retw 1,2,4,8,16,32,64,128
;---- End of routine
;
;Schematic at [url]www.myblueroom.com[/url] see Cricket Communicating Thermostat
;William Richardson 2006
;
DispRefresh setb RP0 ;Bank 1
or RA,#00001111b ;turn off all segments Port A
or RB,#11110000b ;turn off all segments Port B
clrb RP0 ;Bank 0
mov W,Jiffy ;W = 1/256 sec
and W,#00000011b ;bits 0-3 only
mov FSR,W ;FSR = 0 to 3
call BitMask ;convert to Bit Position
mov Temp_A,W ;Temp_B = Bit Position
xor W,#00001111b ;invert lower nibble only (4 Digits only)
or RA,W ;move Output bits to RA 0-3
or RB,#11110000b ;RB = 1111xxxx for (4 digits only)
add FSR,#Display ;Add offset of Display Pointer
mov W,Temp_A ;W = invert Bit Postion
and W,Indf ;and with digit segments
sz ;do we need the float bit?
or W,#10000000b ;Disable float bit
or W,Temp_A ;or the bit positon
or W,Indf ;or the display segments
not W ;invert W (0=output, 1=input/float)
setb RP0 ;bank 1
mov Temp_A,W ;Temp_A = W (I/O mask)
and W,#00001111b ;mask of high nibble
and TRISA,W ;set I/O direction low nibble
mov W,Temp_A ;W = Temp_A
and W,#11110000b ;keep high nibble
and TRISB,W ;set I/O direction high nibble
clrb RP0 ;bank 0