Click here to Skip to main content
Rate this: bad
good
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'
	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 5-Aug-12 7:02am
Edited 5-Aug-12 12:27pm
v4
Comments
Kenneth Haugland at 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 at 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 at 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
good
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
END
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...
  Permalink  
Rate this: bad
good
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 | :)
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 195
1 Afzaal Ahmad Zeeshan 132
2 ProgramFOX 130
3 Maciej Los 105
4 Sergey Alexandrovich Kryukov 75
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 6 Aug 2012
Copyright © CodeProject, 1999-2014
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