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 |
sub function PWM_Init(dim freq_hz as longword) as word |
|---|---|
| Description |
This sub function enables PWM clock, calculates prescaler and counter based on frequency parameter, set continuous mode and disables trigger. |
| Parameters |
|
| Returns |
This sub function returns calculated counter period (used to set duty ratio). |
| Requires |
|
| Example |
duty = PWM_Init(10000) |
| Notes |
None. |
PWM_ConfigChannel
| Prototype |
sub procedure PWM_ConfigChannel(dim dutyRatio as word, dim initState as byte, dim channel as byte) |
||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Description |
This sub 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 |
sub procedure PWM_SoftReset() |
|---|---|
| Description |
This sub procedure resets PWM module. |
| Parameters |
None. |
| Returns |
Nothing. |
| Requires |
Nothing. |
| Example |
' reset PWM module PWM_SoftReset() |
| Notes |
None. |
PWM_EnableOutput
| Prototype |
sub procedure PWM_EnableOutput() |
|---|---|
| Description |
This sub procedure enables PWM module output. |
| Parameters |
None. |
| Returns |
Nothing. |
| Requires |
Nothing. |
| Example |
' Enable PWM module output PWM_EnableOutput() |
| Notes |
None. |
PWM_DisableOutput
| Prototype |
sub procedure PWM_DisableOutput() |
|---|---|
| Description |
This sub 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!



