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 14th March 2006, 07:26 AM   #1
Default Charlieplexed code segment for the Cricket Thermostat

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

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 www.myblueroom.com 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
__________________
Bill
Home of the
Firefly PIC Tutor
Inchworm ICD2

http://www.blueroomelectronics.com
William At MyBlueRoom is offline  
Old 14th March 2006, 10:19 AM   #2
Default

I suspect it may be more useful if it used proper MicroChip assembler, rather than an obscure third party one?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 14th March 2006, 05:12 PM   #3
Default

It's hard to break old habits, I've been using that type of assembler since it was known as the Parallax assembler.
I've got an old clearview 5x in a box somewhere.
__________________
Bill
Home of the
Firefly PIC Tutor
Inchworm ICD2

http://www.blueroomelectronics.com
William At MyBlueRoom is offline  
Reply

Tags
charlieplexed, code, cricket, segment, thermostat

Thread Tools
Display Modes




All times are GMT. The time now is 02:28 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker