| RTOS_MSPM0 1.1 ECE445M starter code

Files | Macros | Functions
RTOS_PWM

Pulse width modulation. More...

## Files
file | RTOS_PWM.h
| Pulse width modulation.

## Macros
#define | PWMUSELFCLK 2
| use PWMUSELFCLK to select LFCLK
#define | PWMUSEMFCLK 4
| use PWMUSEMFCLK to select MFCLK
#define | PWMUSEBUSCLK 8
| use PWMUSEBUSCLK to select bus CLK

## Functions
void | PWM0_Init (uint32_t timerClkSrc, uint32_t timerClkPrescale, uint32_t period, uint32_t duty0, uint32_t duty1)
| Initialize PWM. More...
void | PWM0_SetDuty (uint32_t duty0, uint32_t duty1)
| Set duty cycles. More...
void | PWM1_Init (uint32_t timerClkSrc, uint32_t timerClkPrescale, uint32_t period, uint32_t duty0, uint32_t duty1)
| Initialize PWM. More...
void | PWM1_SetDuty (uint32_t duty0, uint32_t duty1)
| Set duty cycles. More...

## Detailed Description

Pulse width modulation.

PWM pins on the MSPM0G3507
Pin | Description
--- | ---
PA8 | TA0_C0 PWM output
PA9 | TA0_C1 PWM output
PB4 | TA1_C0 PWM output
PB1 | TA1_C1 PWM output

## Function Documentation

## ◆ PWM0_Init()

void PWM0_Init | ( | uint32_t | timerClkSrc,
|  | uint32_t | timerClkPrescale,
|  | uint32_t | period,
|  | uint32_t | duty0,
|  | uint32_t | duty1
| ) |  |

Initialize PWM.

Initialize PWM outputs on PA8 PA9. Rising edge synchronized. timerClkDivRatio = 1. Once started, hardware will continuously output the waves.

- timerClkSrc =
  - 2 for 32768 Hz LFCLK
  - 4 for 4MHz MFCLK (not tested)
  - 8 for 80/32/4 BUSCLK
- TimerA0 is on Power domain PD1
  - for 32MHz bus clock, Timer clock is 32MHz
  - for 40MHz bus clock, Timer clock is MCLK 40MHz
  - for 80MHz bus clock, Timer clock is MCLK 80MHz
- PWMFreq = (timerClkSrc / (timerClkDivRatio * (timerClkPrescale + 1) * period))
  - For example, source=LFCLK, prescale = 0, period = 1000, PWM frequency = 32.768 Hz
  - For example, source=BUSCLK, 80MHz bus, prescale=79, period = 10000, PWM frequency = 100Hz

Parameters

  timerClkSrc | is 2 4 or 8
  timerClkPrescale | divide clock by timerClkPrescale+1, 0 to 255
  period | sets the PWM period
  duty0 | sets the duty cycle on PA8
  duty1 | sets the duty cycle on PA9

Returns
  none

Note
  Assumes LaunchPad_Init has been called to reset and activate power

See also
  PWM0_SetDuty

## ◆ PWM0_SetDuty()

void PWM0_SetDuty | ( | uint32_t | duty0,
|  | uint32_t | duty1
| ) |  |

Set duty cycles.

Set duty cycles on PA12 PA13.

Parameters

  duty0 | sets the duty cycle on PA8
  duty1 | sets the duty cycle on PA9

Returns
  none

Note
  assumes PWM_Init was called

See also
  PWM_Init

## ◆ PWM1_Init()

void PWM1_Init | ( | uint32_t | timerClkSrc,
|  | uint32_t | timerClkPrescale,
|  | uint32_t | period,
|  | uint32_t | duty0,
|  | uint32_t | duty1
| ) |  |

Initialize PWM.

Initialize PWM outputs on PB4 B0. Rising edge synchronized. timerClkDivRatio = 1. Once started, hardware will continuously output the waves.

- timerClkSrc =
  - 2 for 32768 Hz LFCLK
  - 4 for 4MHz MFCLK (not tested)
  - 8 for 80/32/4 BUSCLK
- G0/G8 is on Power domain PD0
  - 32MHz bus clock, BUSCLK clock is 32MHz
  - 40MHz bus clock, BUSCLK clock is ULPCLK 20MHz
  - 80MHz bus clock, BUSCLK clock is ULPCLK 40MHz
- PWMFreq = (timerClkSrc / (timerClkDivRatio * (timerClkPrescale + 1) * period))
  - For example, source=LFCLK, prescale = 0, period = 1000, PWM frequency = 32.768 Hz
  - For example, source=BUSCLK, 80MHz bus, prescale=79, period = 10000, PWM frequency = 100Hz

Parameters

  timerClkSrc | is 2 4 or 8
  timerClkPrescale | divide clock by timerClkPrescale+1, 0 to 255
  period | sets the PWM period
  duty0 | sets the duty cycle on PB4
  duty1 | sets the duty cycle on PB1

Returns
  none

Note
  Assumes LaunchPad_Init has been called to reset and activate power

See also
  PWM1_SetDuty

## ◆ PWM1_SetDuty()

void PWM1_SetDuty | ( | uint32_t | duty0,
|  | uint32_t | duty1
| ) |  |

Set duty cycles.

Set duty cycles on PA12 PA13.

Parameters

  duty0 | sets the duty cycle on PB4
  duty1 | sets the duty cycle on PB1

Returns
  none

Note
  assumes PWM_Init was called

See also
  PWM1_Init