Discussion forum for the BasicX family of microcontroller chips.
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 - 離線訊息 就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。 http://messenger.yahoo.com.hk [Non-text portions of this message have been removed]
> ... 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...> 說:
> ... 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 - 離線訊息
就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
http://messenger.yahoo.com.hk
[Non-text portions of this message have been removed]