Click here to Skip to main content
11,931,104 members (58,288 online)
Rate this:
Please Sign up or sign in to vote.
See more: Microcontroller
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

	movlw	b'10001000'
		movlw	.1
		movwf	N_Minute
                call    DelayiM
DelayiM	sleep
loopiiMM	sleep
		movlw .60
		movwf Seconds
loopi2M			sleep
			movlw .52 
                        movwf j		
loopj2M					sleep	
					decfsz	j,1	
					goto loopj2M
			decfsz	Seconds,1
			goto loopi2M
decfsz N_Minute,1
goto loopiiMM			
Posted 5-Aug-12 7:02am
Edited 5-Aug-12 12:27pm
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
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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

//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
so apparently you have created a delay of 0.000512 seconds. you are few steps away to make it one seconds Smile | :)
now please do the rest...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 Smile | :)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 6 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100