RTOS_MSPM0  1.1
ECE445M starter code
Files | Macros | Functions
PWMA1

Pulse width modulation. More...

Files

file  PWMA1.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 PWMA1_Init (uint32_t timerClkSrc, uint32_t timerClkPrescale, uint32_t period, uint32_t duty0, uint32_t duty1)
 Initialize PWMA1. More...
 
void PWMA1_SetDuty (uint32_t duty0, uint32_t duty1)
 Set duty cycles. More...
 
void PWMA1_Forward (uint32_t duty0)
 Motor forward. More...
 
void PWMA1_Backward (uint32_t duty1)
 Motor backward. More...
 
void PWMA1_Break (void)
 Motor break. More...
 
void PWMA1_Coast (void)
 Motor coast. More...
 

Detailed Description

Pulse width modulation.

PWM pins on the MSPM0G3507
Pin Description
PB4 CCP0 PWM output
PB1 CCP1 PWM output

Function Documentation

◆ PWMA1_Backward()

void PWMA1_Backward ( uint32_t  duty1)

Motor backward.

Set duty cycle on PB1 (time low), and set PB4 high.

Parameters
duty1sets the duty cycle on PB1
Returns
none
Note
assumes PWMA1_Init was called
See also
PWMA1_Init

◆ PWMA1_Break()

void PWMA1_Break ( void  )

Motor break.

Set PB1 high, and set PB4 high.

Parameters
none
Returns
none
Note
assumes PWMA1_Init was called
See also
PWMA1_Init

◆ PWMA1_Coast()

void PWMA1_Coast ( void  )

Motor coast.

Set PB1 low, and set PB4 low. Goes into sleep mode

Parameters
none
Returns
none
Note
assumes PWMA1_Init was called
See also
PWMA1_Init

◆ PWMA1_Forward()

void PWMA1_Forward ( uint32_t  duty0)

Motor forward.

Set duty cycle on PB4 (time low), and set PB1 high.

Parameters
duty0sets the duty cycle on PB4
Returns
none
Note
assumes PWMA1_Init was called
See also
PWMA1_Init

◆ PWMA1_Init()

void PWMA1_Init ( uint32_t  timerClkSrc,
uint32_t  timerClkPrescale,
uint32_t  period,
uint32_t  duty0,
uint32_t  duty1 
)

Initialize PWMA1.

Initialize PWMA1 outputs on PB4, PB1. 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
  • A0/A1 is on Power domain PD1
    • 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=39, period = 10000, PWM frequency = 200Hz
Parameters
timerClkSrcis 2 4 or 8
timerClkPrescaledivide clock by timerClkPrescale+1, 0 to 255
periodsets the PWM period
duty0sets the duty cycle on PB4
duty1sets the duty cycle on PB1
Returns
none
Note
Will call LaunchPad_Init to reset and activate power
See also
PWMA1_SetDuty

◆ PWMA1_SetDuty()

void PWMA1_SetDuty ( uint32_t  duty0,
uint32_t  duty1 
)

Set duty cycles.

Set duty cycles on PB4, PB1.

Parameters
duty0sets the duty cycle on PB4
duty1sets the duty cycle on PB1
Returns
none
Note
assumes PWMA1_Init was called
See also
PWMA1_Init