#include <opwm.h>
Public Member Functions | |
| MICROSECOND | get_hightime (void) |
| return current high time [DOS only] | |
| MICROSECOND | get_lowtime (void) |
| return current low time [DOS only] | |
| void | WSwrite (void) |
| Write object to simulator. | |
| void | hightime (MICROSECOND high) |
| Hightime set the on time for the pulse measured in micro-seconds. | |
| void | nexthigh (MICROSECOND high) |
| Used when oPWM is not operating to set new hightime when activated. | |
| void | lowtime (MICROSECOND low) |
| Lowtime is the off time for the pulse measured in micro-seconds. | |
| void | nextlow (MICROSECOND low) |
| Used when oPWM is not operating to set new lowtime when activated. | |
| void | priority (PRIORITY p) |
| Sets the TPU channel execution priority (Ref. TPU Channel Utilization). Default MIDDLE_PRIORITY. | |
| void | value (bool onoff) const |
| For oDO1_TPU. | |
Static Public Member Functions | |
| int | TCR1 (void) |
| void | TMCR (int iarb) |
| bool | HSQR (int chan, int val) |
| Configures the host sequence register. | |
| bool | HSRR (int chan, int val) |
| Configures the host sequence request register. | |
| bool | CPR (int chan, int val) |
| Configures the channel priority register (Ref. TPU Channel Utilization). | |
| bool | CIER (int chan, int cie) |
| Configures the channel interrupt enable register. | |
| int | CISR (int chan) |
| Returns the channel interrupt status register. | |
| void | CISR_clear (int chan) |
| Clears the channel interrupt status register for the channel. | |
| bool | TICR (int cirl, int cibv) |
| Configures the TPU interrupt configuration register. | |
| int | tpu_vector (IOLINE channel) |
| Given a channel, returns the vector number to use for an interrupt. | |
It is important to understand the relationship between the number of clocks (TCR1P/PSCK) and the internal system clock to obtain the value for the high and low time; we see from the TPU reference manual 2-2 that the number of clocks required to generate a 1 microsecond pulse is 16 clocks at 16 MHz. Therefore, at 8 MHz, the clock is twice as slow which means it takes twice as many (32) clocks per micro second. Similarly if the prescaler is increased, this decreases the effective clock time on the TPU channel. Thus the higher the TPU effective system clock rate, the more clocks I would need to generate to get my 1 microsecond. Finnally, ignoring the round off of integer division, I thus obtain:
value = time_desired*(clock_frequency/number_clocks) example: scale_factor = (.0015 seconds)*(25000000 /32)
or if you divide everything by 1,000,000 since clock_frequency is in millions (rounded to 8,16, or 25MHz) then we can specify the time in one millionth of a second (microseconds). I have since replaced the simple clock_frequency definitions with more accurate float math versions. I felt the bloat was worth it :)
|
||||||||||||
|
Configures the channel interrupt enable register.
|
|
||||||||||||
|
Configures the channel priority register (Ref. TPU Channel Utilization).
|
|
||||||||||||
|
Configures the host sequence register.
|
|
||||||||||||
|
Configures the host sequence request register.
|
|
|
Used when oPWM is not operating to set new hightime when activated. DCmotor (and maybe like objects) needs this, because the only way to stop the PWM (that I know of) is to set hightime to 0--thus loosing the previous value of hightime. thus if you set the hightime while the object is non-operational, you want it to be set to that value the next time the object goes operational (see dcmotor.cpp to know what I'm talking about). |
|
|
misnomer--should be TCR1 divisor--return number of clocks (PSCK,TCR1P modifications) Globally available object. Can be used in combination with TPU_REGISTER definition to say TPU_REGISTER->CFSR.BITS... |
|
|
was tpu_init Configures the channel function select register |
1.3