Project 1 - A Clock for the Shack
Decimal Point


Problem:
No details are given on how to light the decimal point. Indeed, if the instructions are followed, all the decimal points on all of the digits will light.

Solution:
On my clock, I hard wired the decimal point of the second digit to zero volts via a 180 ohm resistor, which is the simplest solution. However, we missed this when we moved the display into a different section. To make the change is software, change the table so that the decimal point is normally out.
RETLW 0x81 ;Zero
RETLW 0xD7 ;One
RETLW 0xA2 ;Two
RETLW 0x92 ;Three
RETLW 0xD4 ;Four
RETLW 0x98 ;Five
RETLW 0x88 ;Six
RETLW 0xD3 ;Seven
RETLW 0x80 ;Eight
RETLW 0xD0 ;Nine
RETLW 0x8F ;10 = "U"
RETLW 0xAC ;11 = "T"
RETLW 0xAE ;12 = "C"

Then, change the display code by adding the code in bold so that the decimal point is lit on the second character:
;Update Display

TICK	MOVLW	0xFF
	MOVWF	PORTB     ;Clear Display

	MOVF	DIGIT, W  ;Update PortA
ADDLW 0x04
ANDLW 0x1C
MOVWF DIGIT MOVWF PORTA INCF CHAR, W ;Update character ANDLW 0x07 MOVWF CHAR ADDLW 0x10 MOVWF FSR MOVF INDR, W ;Get char ANDLW 0x0F CALL TABLE ;Returns with display in W MOVWF 0x21 ;STORE RESULTS IN TEMPORARY REGISTER MOVF CHAR, W ;MOVE OFFSET TO W XORLW 0x01 ;IS IT SECOND DIGIT BTFSS STATUS,2 ;CHECK ZERO BIT GOTO OK ;NOT THIS DIGIT MOVLW 0x80 ;THIS DIGIT SO SWITCH ON DOT SUBWF 0x21, 1 OK MOVF 0x21, 0 ;GET CHARACTER TO DISPLAY MOVWF PORTB MOVLW 0xC9 MOVWF DELAY LOOP1 DECFSZ DELAY, F GOTO LOOP1
Note that this will take some additional time and therefore the delay loops will also need to be modified.

Other Projects:
This change does not affect the other projects.

Alternatives:
If you have Followed the alternative solution for wiring up the display board:
Change the routine called "TABLE" to the one given below:

ADDWF  	PCL, F
RETLW 0x09 ;Zero RETLW 0xED ;One RETLW 0x43 ;Two RETLW 0xC1 ;Three RETLW 0xA5 ;Four RETLW 0x91 ;Five RETLW 0x31 ;Six RETLW 0xCD ;Seven RETLW 0x01 ;Eight RETLW 0x85 ;Nine RETLW 0x0F ;Letter "U"> RETLW 0x2D ;Letter "T" RETLW 0x2F ;Letter "C" RETLW 0xFF ;13 RETLW 0xFF ;14 RETLW 0xFF ;15 RETLW 0xFF ;16
Then change the additional code:

	MOVWF	0x21	   ;STORE RESULTS IN TEMPORARY REGISTER
	MOVF	CHAR, W	   ;MOVE OFFSET TO W
	XORLW   0x01	   ;IS IT SECOND DIGIT
	BTFSS   STATUS,2   ;CHECK ZERO BIT
	GOTO	OK	   ;NOT THIS DIGIT

	DECF	0x21, 1	   ;THIS DIGIT SO SWITCH ON DOT

OK	MOVF	0x21, 0	   ;GET CHARACTER TO DISPLAY


See also:
Pin connections missing from the book.


Further information:
I hope that this page helps you with your projects but if you have found any other problems or if you have any further questions please contact me though the email address of gares-AT-g4aym-DOT-org-DOT-uk.

Sorry about the email address but it seems to be the only way to avoid the spammers



Click here to return to the PIC Basics Main Page

Click here for the Index of Errors and Ommissions