PWM library
The PWM module is available with a number of MCUs. mikroC PRO for FT90x provides a library which simplifies usage of this module.
Library Routines
PWM_Init
Prototype |
unsigned int PWM_Init(unsigned long freq_hz); |
---|---|
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 |
pwm_period = PWM_Init(250000); |
Notes |
None. |
PWM_ConfigChannel
Prototype |
void PWM_ConfigChannel(unsigned int dutyRatio, unsigned char initState, unsigned char channel); |
||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
void PWM_SoftReset(); |
---|---|
Description |
This function resets PWM module. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
// reset PWM module PWM_SoftReset(); |
Notes |
None. |
PWM_EnableOutput
Prototype |
void PWM_EnableOutput(); |
---|---|
Description |
This function enables PWM module output. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Example |
// Enable PWM module output PWM_EnableOutput(); |
Notes |
None. |
PWM_DisableOutput
Prototype |
void PWM_DisableOutput(); |
---|---|
Description |
This function 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!