PWM library
The PWM module is available with a number of MCUs. mikroPascal PRO for FT90x provides a library which simplifies usage of this module.
Library Routines
PWM_Init
Prototype |
function PWM_Init(freq_hz : dword) : word; |
---|---|
Description |
This function enables PWM clock, calculates prescaler and counter based on frequency parameter, set continuous mode and disables trigger. |
Parameters |
|
Returns |
This function returns calculated counter period (used to set duty ratio). |
Requires |
|
Example |
duty := PWM_Init(10000); |
Notes |
None. |
PWM_ConfigChannel
Prototype |
procedure PWM_ConfigChannel(dutyRatio : word; initState : byte; channel : byte); |
||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function configure PWM channel (sets duty ratio, outputs initial level), and enables PWM output to corresponding pad. |
||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||
Example |
PWM_ConfigChannel(current_duty, _PWM_INIT_STATE_0, _PWM_CHANNEL_4); // PWM output on P52 pin |
||||||||||||||||||||||||
Notes |
None. |
PWM_SoftReset
Prototype |
procedure PWM_SoftReset(); |
---|---|
Description |
This procedure resets PWM module. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
// reset PWM module PWM_SoftReset(); |
Notes |
None. |
PWM_EnableOutput
Prototype |
procedure PWM_EnableOutput(); |
---|---|
Description |
This procedure enables PWM module output. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
// Enable PWM module output PWM_EnableOutput(); |
Notes |
None. |
PWM_DisableOutput
Prototype |
procedure PWM_DisableOutput(); |
---|---|
Description |
This procedure disables PWM module output. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
// Disable PWM module output PWM_DisableOutput(); |
Notes |
None. |
What do you think about this topic ? Send us feedback!