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 12th February 2009, 05:58 AM   #1
Default loop time out

still trying to learn assembly

If I'm thinking right this would loop until PORTA,1 is set
but if I needed it to carry on if PORTA,1 does not set in say 20 sec.
what would be the best way to do it in assembly


BTFSC PORTA,1
GOTO AUNT NANCY'S
GOTO $-2
GOTO UNCLE Bob'S

something like this is how I would do it in Pic Basic Pro

A VAR WORD
For A= 0 TO 20000 '20 SEC.
Pause 1
IF PORTA,1 =1 Then
goto aunt Nancy's

EndIF
Next A
goto uncle Bob's


thanks to all
homemade24 is offline  
Old 12th February 2009, 07:48 AM   #2
Default

Hi,

Labels need to be one word in assembler e.g. AUNT_NANCY'S, UNCLE_Bob'S.


As for the time maybe something like;
Code:
BTFSC Timer1_done_bit ;has timer 1 timed out (overflowed)?
GOTO UNCLE_Bob'S      ;yes it has
BTFSC PORTA,1         ;no it has not
GOTO AUNT_NANCY'S  
GOTO $-4

UNCLE_Bob'S:
bcf     Timer1_done_bit
Note:
('Timer1_done' is a made up label)

Last edited by Angry Badger; 12th February 2009 at 07:51 AM. Reason: Added code tags
Angry Badger is offline  
Old 12th February 2009, 08:36 AM   #3
Default

You can do it pretty much the same as your basic program,

Code:
		movlw	high(.20000)+1
		movwf	CounterHi
		movlw	low(.20000)
		movwf	CounterLo
WaitPortA	call	Delay1mS
		btfsc	PORTA,1
		goto	Done
		decfsz	CounterLo,F
		goto	WaitPortA
		decfsz	CounterHi,F
		goto	WaitPortA
Done		nop
The Delay1mS code is also rather simple,
Code:
Delay1mS	movlw	.249
DelayLoop	addlw	.255
		btfss	STATUS,Z
		goto	DelayLoop
		return
This assumes a 4MHz oscillator.

Mike.
Pommie is online now  
Old 12th February 2009, 02:33 PM   #4
Default

Thanks Guy just what the doctor ordered
different people have to learn things different ways
and hate to say it but I'm one of the one that has to do it on a "as need be bases"
because tomorrow when I wake up I will have forgot not only how I did something
BUT WHY I EVEN DID IT
as always thanks
homemade24 is offline  
Reply

Tags
loop, time

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Continious time loop computer Jarek Duda Electronic Projects Design/Ideas/Reviews 14 28th December 2008 09:49 PM
555 timer (t= 13 minutes) On-time = Off-time greenmeup Electronic Projects Design/Ideas/Reviews 11 12th September 2008 08:18 AM
MPLAB C18, Added a Nop() to loop, decreased execution time? Fred.Amoson Micro Controllers 6 22nd April 2008 03:23 AM
FOR loop in C eblc1388 Micro Controllers 12 10th January 2007 11:24 PM
Enquiry For Discrete Time Convolution & continuous time shermaine General Electronics Chat 3 4th August 2004 09:25 PM



All times are GMT. The time now is 04:43 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker