Functions | |
int | Pwm_Set (int index, int duty) |
Set the duty of a PWM device. | |
int | Pwm_Get (int index) |
Read the current duty of a PWM device. | |
int | Pwm_SetDividerA (int val) |
Adjust the clock period on Divider A. | |
int | Pwm_GetDividerA () |
Read the clock period on Divider A. | |
int | Pwm_SetDividerB (int val) |
Adjust the clock period on Divider B. | |
int | Pwm_GetDividerB () |
Read the clock period on Divider B. | |
int | Pwm_SetClockSource (int channel, int val) |
Set the clock divider for a particular channel. | |
int | Pwm_GetClockSource (int channel) |
Read the clock source for a particular channel. | |
int | Pwm_SetWaveformProperties (int channel, int val) |
Set the wave form properties of the PWM contoller for a given channel. | |
int | Pwm_GetWaveformProperties (int channel) |
Read the waveform configuration of a specified PWM channel. |
The Make Controller has 4 PWM lines. These can each be configured separately and can control up to 2 output lines directly, the 2 lines running either parallel or inverted. For a very simple start, just see Pwm_Set( ) and Pwm_Get( ) as these will start driving your PWMs immediately with very little hassle.
Each of the 4 PWM channels is fed in a clock, as determined by its clock source:
If either Clock Divider A or Clock Divider B is used, you can adjust their values individually to allow the clock period to precisely match your needs. Each clock divider has two values, a Mux value and a Divider value.
The mux works just like the clock source values, and chooses Master clock divided by 2 to the power of the Clock Source Value, eg. a DividerXMux value of 5 == a clock rate of MasterClock/(2^5). The Divider value sets a linear divider, which is fed the clock value as selected by the Mux, and returns that clock value divided by the divider value. This output value is what is fed out of the divider unit. A output formula:
output = MCLK / ( (2^DividerMux) * DividerValue )
The PWM subsystem of the Controller Board can be used independently from the PWM Out library, since the PWM Out library relies on the core PWM.
int Pwm_Get | ( | int | index | ) |
int Pwm_GetClockSource | ( | int | channel | ) |
Read the clock source for a particular channel.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
channel | The PWM channel (0-3) whose channel you'd like to read. |
int Pwm_GetDividerA | ( | void | ) |
Read the clock period on Divider A.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
int Pwm_GetDividerB | ( | void | ) |
Read the clock period on Divider B.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
int Pwm_GetWaveformProperties | ( | int | channel | ) |
Read the waveform configuration of a specified PWM channel.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
channel | The PWM channel (0-3) to read from. |
int Pwm_Set | ( | int | index, | |
int | duty | |||
) |
int Pwm_SetClockSource | ( | int | channel, | |
int | val | |||
) |
Set the clock divider for a particular channel.
For values 0-10, the Master_Clock is divided by (2^val). For example, for 4 the resulting period will be Master Clock / 16, as 2 ^ 4 == 16.
When val is 11, Clock Divider A is used. When val is 12, Clock Divider B is used. Values other than 0 - 12 are not valid.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
channel | The PWM channel (0-3) you'd like to configure. | |
val | The new clock divider. |
int Pwm_SetDividerA | ( | int | val | ) |
Adjust the clock period on Divider A.
See AT91SAM7X manual for more information p.421
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
val | An int between 0 and 4096. |
int Pwm_SetDividerB | ( | int | val | ) |
Adjust the clock period on Divider B.
See AT91SAM7X manual for more information p.421
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
val | An int between 0 and 4096. |
int Pwm_SetWaveformProperties | ( | int | channel, | |
int | val | |||
) |
Set the wave form properties of the PWM contoller for a given channel.
The waveform properties are controlled by bits 0, 1, and 2.
Contributed by TheStigg - http://www.makingthings.com/author/thestigg
channel | the PWM channel (0-3) that you want to configure | |
val | The mask of values as described above. |