PWM & Timer

Started by soso soso March 2, 2006
Hi~
   
  I have a question about timer. In my applicaiton, PWM is always used to
control a DC motor, but I also want to use the command "timer" to
calcuate the time interval of a function. for example:
	  main()
  CallTask "PWM_Task", PWM_STACK         'a PWM task that always run
   
  do
  A = timer
  call function()                     'just a example function
  B = timer
  time interval  = B - A
  loop
   
  end Sub
   
  is it possible to achieve? or any other suggestion that can calcuate the time
interval while the PWM is running
   
  Thanks
  Owen

_______________________________________
 YM - uT
 NSWABͤiHdUTAAWNYݨܳC
 http://messenger.yahoo.com.hk


	
 > ... I also want to [] calculate the time interval...

PWM and timing can coexist, yes, since there are three timer/counters, 
Timer0, Timer1 and Timer2, and they can each can do different things.

Timer0 is dedicated to Basic-X OS functions, like switching tasks, 
checking queues and keeping the system clock.  I suggest that you don't 
manipulate it, but it is the time source of function Timer() so you will 
implicitly and indirectly use Timer0 when you use that or any of the 
other standard system time functions.

Timer1 and Timer2 can also be used for other time- and count-related 
functions, like PWM.  Timer1 can produce one or two PWM signals 
simultaneously, with 8, 9, or 10-bit resolution on BX-24 pins 26 and 27; 
see the application note "Programming Timer1 for Dual Pulse Width 
Modulation".

Timer2 can also generate an 8-bit PWM signal (on pin 25) so, 
theoretically, you can generate three PWMs and keep an event clock with 
512Hz resolution, simultaneously.  You can also use either Timer1 or 
Timer2 as a high-speed timer or counter within the range and resolution 
they offer

Be aware that some system functions use Timer1 or Timer2.  Using COM3, 
for example, implicitly requires Timer2.  Pulse, Capture and Shift 
functions all use Timer1, I believe.
	Tom
	
Thanks Tom~ I now understand more about BX24
   
  Owen

Tom Becker <gtbecker@gtbe...> G
  > ... I also want to [] calculate the time interval...

PWM and timing can coexist, yes, since there are three timer/counters, 
Timer0, Timer1 and Timer2, and they can each can do different things.

Timer0 is dedicated to Basic-X OS functions, like switching tasks, 
checking queues and keeping the system clock.  I suggest that you don't 
manipulate it, but it is the time source of function Timer() so you will 
implicitly and indirectly use Timer0 when you use that or any of the 
other standard system time functions.

Timer1 and Timer2 can also be used for other time- and count-related 
functions, like PWM.  Timer1 can produce one or two PWM signals 
simultaneously, with 8, 9, or 10-bit resolution on BX-24 pins 26 and 27; 
see the application note "Programming Timer1 for Dual Pulse Width 
Modulation".

Timer2 can also generate an 8-bit PWM signal (on pin 25) so, 
theoretically, you can generate three PWMs and keep an event clock with 
512Hz resolution, simultaneously.  You can also use either Timer1 or 
Timer2 as a high-speed timer or counter within the range and resolution 
they offer

Be aware that some system functions use Timer1 or Timer2.  Using COM3, 
for example, implicitly requires Timer2.  Pulse, Capture and Shift 
functions all use Timer1, I believe.
	Tom
	  SPONSORED LINKS 
        Microcontrollers   Microprocessor   Intel microprocessors     Pic
microcontrollers 
    
---------------------------------
  YAHOO! GROUPS LINKS
	---------------------------------
	_______________________________________
 YM - uT
 NSWABͤiHdUTAAWNYݨܳC
 http://messenger.yahoo.com.hk