Infineon Logo AIROC BTSDK v4.6 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups

Macros

#define pwmIdToMask(id)   (1<<id)
 Defines the standard PWM driver. More...
 

Enumerations

enum  {
  PWM0 = 0, PWM1 = 1, PWM2 = 2, PWM3 = 3,
  MAX_PWMS = 4
}
 PWM HW block has 4 PWM channels each with its own 10 bit counter. More...
 
enum  PwmClockType { LHL_CLK, PMU_CLK }
 Clock used for PWM. When LHL_CLK is set, 128 KHz is used. When PMU_CLK is set, 1 MHz or 8 MHz. More...
 
enum  { PWM_CHANNEL_MASK = 0x0F }
 
enum  {
  PWM0_OUTPUT_ENABLE_P26 = GPIO_OUTPUT_ENABLE, PWM1_OUTPUT_ENABLE_P27 = GPIO_OUTPUT_ENABLE, PWM2_OUTPUT_ENABLE_P28 = GPIO_OUTPUT_ENABLE, PWM2_OUTPUT_ENABLE_P6 = (GPIO_OUTPUT_ENABLE | (1 << 4)),
  PWM2_OUTPUT_ENABLE_P14 = (2 << 4), PWM3_OUTPUT_ENABLE_P29 = GPIO_OUTPUT_ENABLE, PWM3_OUTPUT_ENABLE_P13 = (2 << 4)
}
 

Functions

BOOL32 pwm_start (UINT8 id, PwmClockType clk, UINT32 toggleCount, UINT32 InitCount)
 Start a PWM. More...
 
BOOL32 pwm_transitionToSubstituteValues (UINT8 id, UINT32 toggleCount, UINT32 InitCount)
 Transitions to another set of pulse modulation values. More...
 
BOOL32 pwm_startWithAlternateValues (UINT8 id, PwmClockType clk, UINT32 toggleCount, UINT32 InitCount, BOOL32 invert)
 Alternate between another set of pulse modulation values and current values. More...
 
UINT32 pwm_getToggleCount (UINT8 id)
 Get the toggleCount of the PWM channel. More...
 
UINT32 pwm_getInitValue (UINT8 id)
 Get the Init Value of the PWM channel. More...
 
BOOL32 pwm_setToggleCount (UINT8 id, UINT32 toggleCount)
 Set toggleCount. More...
 
void pwm_setInversion (UINT8 id, BOOL32 invert)
 Set if output should be inverted or not. More...
 
BOOL32 pwm_setValues (UINT8 id, UINT32 toggleCount, UINT32 initCount, PwmClockType clk, BOOL32 invert)
 Set the values of the given PWM channel. More...
 
void pwm_setClock (UINT8 id, PwmClockType clk)
 Set the clock. More...
 
void pwm_setInitValue (UINT8 id, UINT32 InitCount)
 Set the Initial Value of the Counter. More...
 
void pwm_resetInternalCount (UINT32 mask)
 Reset the internal counter. Internal, not for application use.
 
void pwm_enableChannel (UINT32 mask)
 Enable the given PWM channels. More...
 
void pwm_disableChannel (UINT32 mask)
 Disable the given PWM channels. More...
 
void pwm_setReset (UINT32 mask, BOOL32 resetEnable)
 Reset the PWM channels. More...
 

Detailed Description

Macro Definition Documentation

#define pwmIdToMask (   id)    (1<<id)

Defines the standard PWM driver.

The PWM uses the ACLK as a reference clock and the counts are incremented at the ACLK edges starting at init value. When the count reaches toggle value, the PWM channel output is inverted and when the count reaches 0x3FF, the output is inverted again and the count wraps around to init value and so on. When a 50% duty cycle is called for, ensure that init value is the same distance from toggle value as toggle value is from 0x3FF.

The 4 PWM channels are output to GPIOs P26, P27, P28 and P29. Once the PWM is configured, the corresponding GPIO must also be output enabled using gpio_configurePin.PWM HW block has 4 PWMs Channels(10 bit) This macros enable to switch from Pwm to its mask value. These mask values are used in enable/disable case.

Enumeration Type Documentation

anonymous enum

PWM HW block has 4 PWM channels each with its own 10 bit counter.

The first PWM id is PWM0;

anonymous enum
Enumerator
PWM_CHANNEL_MASK 

PWM Channel Mask.

anonymous enum
Enumerator
PWM0_OUTPUT_ENABLE_P26 

PWM0 Output enable on P26.

PWM1_OUTPUT_ENABLE_P27 

PWM1 Output enable on P27.

PWM2_OUTPUT_ENABLE_P28 

PWM2 Output enable pn P28.

PWM2_OUTPUT_ENABLE_P6 

PWM2 Output enable on P6.

PWM2_OUTPUT_ENABLE_P14 

PWM2 Output enable on P14.

PWM3_OUTPUT_ENABLE_P29 

PWM3 Output enable on P29.

PWM3_OUTPUT_ENABLE_P13 

PWM3 Output enable on P13.

Clock used for PWM. When LHL_CLK is set, 128 KHz is used. When PMU_CLK is set, 1 MHz or 8 MHz.

Enumerator
LHL_CLK 

The 128KHz internal reference clock, continues to run in sleep.

Max possible PWM frequency is ~64KHz.

PMU_CLK 

The programmable clock derived from aclk, does not run in sleep.

Max possible PWM frequency is ~12MHz.

Function Documentation

void pwm_disableChannel ( UINT32  mask)

Disable the given PWM channels.

Parameters
mask- the PWD channels to disable.
void pwm_enableChannel ( UINT32  mask)

Enable the given PWM channels.

Parameters
mask- the PWD channels to enable.
UINT32 pwm_getInitValue ( UINT8  id)

Get the Init Value of the PWM channel.

Parameters
id- the PWD channel.
Returns
- initvalue or the Init value of the PWM.
UINT32 pwm_getToggleCount ( UINT8  id)

Get the toggleCount of the PWM channel.

Parameters
id- the PWM channel.
Returns
- the value at which the PWM is going to toggle.
void pwm_setClock ( UINT8  id,
PwmClockType  clk 
)

Set the clock.

Parameters
id- the PWD channel.
clk- which clockspeed to use.
void pwm_setInitValue ( UINT8  id,
UINT32  InitCount 
)

Set the Initial Value of the Counter.

Parameters
id- the PWD channel.
InitCount- The initial count to use for the given channel.
void pwm_setInversion ( UINT8  id,
BOOL32  invert 
)

Set if output should be inverted or not.

This is not glitch free.

Parameters
id- the PWD channel.
invertWhether to invert the output or not. When TRUE, output will be inverted.
void pwm_setReset ( UINT32  mask,
BOOL32  resetEnable 
)

Reset the PWM channels.

Parameters
mask- the PWD channels to enable/disable.
resetEnable- When TRUE, channels will be disabled, when FALSE, channels will be enabled.
BOOL32 pwm_setToggleCount ( UINT8  id,
UINT32  toggleCount 
)

Set toggleCount.

Not glitch free.

Parameters
id- the PWD channel.
toggleCount- value on which a toggle happens.
Returns
whether setToggleCount was successful.
BOOL32 pwm_setValues ( UINT8  id,
UINT32  toggleCount,
UINT32  initCount,
PwmClockType  clk,
BOOL32  invert 
)

Set the values of the given PWM channel.

Parameters
id- the PWD channel.
toggleCount- value on which a toggle happens.
InitCount- initial value for the counter.
clk- which clockspeed to use.
invert- if invert bit is on.
Returns
TRUE if the values are set; else false.
BOOL32 pwm_start ( UINT8  id,
PwmClockType  clk,
UINT32  toggleCount,
UINT32  InitCount 
)

Start a PWM.

Parameters
id- the PWD channel.
clk- which clockspeed to use.
toggleCount- value on which a toggle happens.
InitCount- initial value for the counter.
Returns
whether the start is successful.
BOOL32 pwm_startWithAlternateValues ( UINT8  id,
PwmClockType  clk,
UINT32  toggleCount,
UINT32  InitCount,
BOOL32  invert 
)

Alternate between another set of pulse modulation values and current values.

Parameters
id- the PWD channel.
clk- which clockspeed to use.
toggleCount- value on which a toggle happens.
phaseCount- initial value for the counter.
invert- whether to invert the signal.
Returns
whether the operation is successful.
BOOL32 pwm_transitionToSubstituteValues ( UINT8  id,
UINT32  toggleCount,
UINT32  InitCount 
)

Transitions to another set of pulse modulation values.

Parameters
id- the PWD channel.
toggleCount- value on which a toggle happens.
InitCount- initial value for the counter.
Returns
whether the transition is successful.