PIC Count Down Timer Help

Status
Not open for further replies.

jay543_uk

New Member
Hi
I have been making a pcb exposure box and am trying to make a count down timer for it so it turns off after the count down finishes. It all seemed pritty simple and i have the counter working but now iv tried to add some code to set the timer it keeps getting stuck in the same loop every time.

The main loop calls a bit of code called "SetTime" which sets mins10, mins , secs10 and sec, It all works fine antil i get to the "setsecs" when it doesnt seem to reconize me pushing the buttons attached to portB pins 4 & 5.I can watch it in debug on a pic2 and it just dosent see any keys being pressed.
It should work that pin 4 increases the number by 1 each push and pin 5 sets it and moves onto the next number.
Please help, This is one of my first codes/ projects iv done so sorry if it not done the proper way but iv just been studying code on line and trying to get it to work for me.

thanks for any help

jason

Code:
;**************************************************************************
;			SetTimer Loop													*
;****************************************************************************

SetTimer
	CALL	WaitRight			;wait for right button to be released
	CALL	CLRDISP				;clear LCD display
	MOVLW	LCD_HOME			;Home position of LCD
	CALL	LCD_POSITION 		;Send command to LCD

	call SetTime_LCD			;Draws Set Timer Message on LCD


setmins10
	MOVLW	LCD_L2				;goto second line on LCD
	CALL	LCD_POSITION		
	CALL	DISPTIMER			;Draws the timer numbers on the LCD
	BTFSS	RightKey			;Test Right button is pushed
	GOTO	setmins				;Move to Next number to be set
	BTFSC	LeftKey				;Test if left button is pushed
	GOTO	setmins10			;If  no buttons pushed then reloop to setmins10
	call	WaitLeft			;Wait for left button to be pushed
	incf	mins10,f			;increase mins10 by 1
	GOTO	setmins10			;reloop to setmins
setmins
	CALL	WaitRight
	MOVLW	LCD_L2
	CALL	LCD_POSITION
	CALL	DISPTIMER
	BTFSS	RightKey
	GOTO	setsecs10
	BTFSC	LeftKey
	GOTO	setmins
	call	WaitLeft
	incf	mins,f
	GOTO	setmins
setsecs10
	CALL	WaitRight
	MOVLW	LCD_L2
	CALL	LCD_POSITION
	CALL	DISPTIMER
	BTFSS	RightKey
	GOTO	setsecs
	BTFSC	LeftKey
	GOTO	setsecs10
	call	WaitLeft
	incf	sec10,f
	GOTO	setsecs10
setsecs
	CALL	WaitRight
	MOVLW	LCD_L2
	CALL	LCD_POSITION
	CALL	DISPTIMER
	BTFSS	RightKey
	GOTO	endloop
	BTFSC	LeftKey
	GOTO	setsecs
	call	WaitLeft
	incf	sec,f
	GOTO	setsecs
endloop
	CALL	WaitRight
	retlw 	0
 
The first thing to do is add coments for each instruction.
Then look to see if you have used a particlular file for two different jobs.
Finally, provide a description of what the program is doing and supply ALL the relevant code.
It's like expecting me to comment on the workings of all your staff by letting me look through a crack in the canteen wall.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…