Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hellow members
i am trying my best to delay the pic for 1 minute,i am configuring the device
at internal oscilator and watchdog enabled,the OPTION_REG=10001000.
i wonder if i should ALSO count total numbers of lines and multiply it by 1/64 to get time required for all instruction
need your fine comments

C#
	movlw	b'10001000'
	movwf	OPTION_REG
.
.
.
		movlw	.1
		movwf	N_Minute
                call    DelayiM
.
.
.
DelayiM	sleep
		sleep	     
loopiiMM	sleep
		movlw .60
		movwf Seconds
loopi2M			sleep
			sleep
			movlw .52 
                        movwf j		

loopj2M					sleep	
					clrwdt
					decfsz	j,1	
					goto loopj2M
			decfsz	Seconds,1
			goto loopi2M
decfsz N_Minute,1
goto loopiiMM			
return
Posted
Updated 5-Aug-12 11:27am
v4
Comments
Kenneth Haugland 5-Aug-12 12:09pm    
What is the language of the pic controller, this is so long ago that I dont remember the specific code any more...
PS: You should proberbly edit the code, it dosnt look quite right to me :)
Mohibur Rashid 5-Aug-12 14:39pm    
I did this long time ago, cant remember much, how about using external clock? you can send interrupt using external clock to wake up the controller
Khalid Sabtan 5-Aug-12 17:14pm    
i have improved the code,it is in an assembly for the pic microcontroller .I prefer to post the complete code but this might be undesirable to the site(if every one post his/her program something me be becomming bigger) any way
i will wait for more time for an answer if not i shall post the whole program

I have forgotten how I created delay.

But I can remember that I used to do some calculation.
first learn what is your pic clock speed.
if you are using 4Mhz crysta you will get 1Mhz clock speed. I totally forgot why.
so in 1Mhz you are getting 1,000,000 cycle.
so write a function to get 255*2+2 cycle

C++
//i forgot how to declare a function 
;if you call this function with 255 data then you will get 255*2+2=512 cycle
func1 macro TIME //calling this function will give 255 cycle.
   DECFSZ TIME, 1 ; this will give 255 cycle
   NOP ; this will give 255 cyle
END

so apparently you have created a delay of 0.000512 seconds. you are few steps away to make it one seconds :)
now please do the rest...
 
Share this answer
 
I dont think anybody could know that without a serious look at the documentation form the microcontroller. THis is highly unusual question, as most people here have specialized in higher languanges. So I guess google is your friend at this one :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900