Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 29th, 2007, 3:12 PM   #1
kyazh1
Newbie
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0 kyazh1 is on a distinguished road
PIC10F206, TOCKI not shutting off so I can use GP2... help?

Hello folks, I have a PIC10F206 Im working with here. It is connected to 3 LED's on GP0 GP1 GP2, and a push button switch that shorts to ground on GP3. GP0 does nothing, GP1 and GP2 are supposed to start blinking when the button is pushed. I'm having some trouble with the setup. It appears that GP2 is using the TOCKI option somehow, although I believe I have that disabled by setting bit 5 in the option to 0. When I push the button, GP1 starts blinking too, So I know that the program is functioning, Im just having a hard time with setup. How do I shut of TOCKI and make GP2 an output? Thanks in advance.


;
;


#include P10F206.INC	; standard Microchip register names definitions
#include header.inc  	; standard header stuff including OSCCAL save and GOTO MAIN

	__config (_MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC )





dly0.5msec			; 0.5msec delay
	MOVLW	D'100'
	MOVWF	DDY0
dl0.5_0	
	DECFSZ	DDY1, 1
	GOTO	dl100_0
	DECFSZ	DDY0, 1
	GOTO	dl100_1
	RETLW	0




dly100msec			; 100msec delay accomplished by just idling in a loop
	MOVLW	D'130'
	MOVWF	DDY0		; load the outer loop delay
dl100_1
	MOVLW	D'255'	
	MOVWF	DDY1		; load the inner loop delay
dl100_0	
	DECFSZ	DDY1, 1
	GOTO	dl100_0
	DECFSZ	DDY0, 1
	GOTO	dl100_1
	RETLW	0
	
MAIN				; here we start the main program with some setup stuff
	MOVLW	B'00001111'
	OPTION			; set up WDT with a long prescale; wakeup on pin change
	MOVLW	B'11110111'
	MOVWF	CMCON0		; set up comparator controls so they don't get in the wayo they don't get in the way

	MOVLW	B'00001001'	; Tris controls
	TRIS	GPIO

;***************************************************************************
; here we really get started on the program



buttonstate
	CALL	dly100msec	; wait for button-bounce
	BTFSS	GPIO, 3		; check if button is high, if so skip the next step

step_loop	
	BSF	GPIO, 1		; Set GPIO,1 high
	BSF	GPIO, 2		; Set GPIO,2 high
	CALL	dly0.5msec	; wait for 0.5msec
	BCF	GPIO, 1		; Set GPIO,1 low
	BCF	GPIO, 2		; Set GPIO,2 low


	GOTO	MAIN

	END
kyazh1 is offline   Reply With Quote
Old Jun 29th, 2007, 3:54 PM   #2
kyazh
Newbie
 
Join Date: Apr 2007
Posts: 3
Rep Power: 0 kyazh is on a distinguished road
well now that I've fiddled with it a bit more, it seem to be the 'buttonstate' or more specifically the BTFSS command that not working like it should be ... any suggestions?

Whats supposed to happen is when I push the button that is attached to GP3, GP1 and GP2 should start pulsing. It will get a bit more complicated than that, but I think its better to do this 1 step at a time. Thanks again!
kyazh is offline   Reply With Quote
Old Jun 29th, 2007, 4:29 PM   #3
kyazh
Newbie
 
Join Date: Apr 2007
Posts: 3
Rep Power: 0 kyazh is on a distinguished road
Heres the updated code. When I push the button on GP3, the LEDs on GP1 & GP2 blink. Now, I need to set up some type of count down, so that when I push the button and release it, the LED's will continue blinking for anouther 5 seconds. I can't figure out how to tell the PIC10F206 how to do two things at once?


;
;


#include P10F206.INC	; standard Microchip register names definitions
#include header.inc  	; standard header stuff including OSCCAL save and GOTO MAIN

	__config (_MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC )





dly0.5msec			; 0.5msec delay
	MOVLW	D'50'
	MOVWF	DDY0
dl0.5_0	
	DECFSZ	DDY1, 1
	GOTO	dl100_0
	DECFSZ	DDY0, 1
	GOTO	dl100_1
	RETLW	0




dly100msec			; 100msec delay accomplished by just idling in a loop
	MOVLW	D'130'
	MOVWF	DDY0		; load the outer loop delay
dl100_1
	MOVLW	D'255'	
	MOVWF	DDY1		; load the inner loop delay
dl100_0	
	DECFSZ	DDY1, 1
	GOTO	dl100_0
	DECFSZ	DDY0, 1
	GOTO	dl100_1
	RETLW	0
	

step_loop	
	BSF	GPIO, 1		; Set GPIO,1 high
	BSF	GPIO, 2		; Set GPIO,2 high
	GOTO	dly0.5msec	; wait 
	BCF	GPIO, 1		; Set GPIO,1 low
	BCF	GPIO, 2		; Set GPIO,2 low
	GOTO	dly0.5msec	; wait 





MAIN				; here we start the main program with some setup stuff

	MOVLW	B'00011111'
	OPTION			; set up WDT with a long prescale; wakeup on pin change
	MOVLW	B'11110111'
	MOVWF	CMCON0		; set up comparator controls so they don't get in the way

	MOVLW	B'00001001'	; set up to load tristate controls
	TRIS	GPIO		; load tristate controls
;***************************************************************************
; here we really get started on the program


buttonstate
	BCF	GPIO, 1
	BCF	GPIO, 2
	CALL	dly100msec	; wait for button-bounce
	BTFSS	GPIO, 3		; check if button is high, if so skip the next step
	CALL	step_loop
	GOTO	buttonstate


	END

Last edited by kyazh; Jun 29th, 2007 at 4:51 PM.
kyazh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC