21. lpc17xx_pwm Module

PWM client library functions. Find implementation details in LPC17xx CMSIS-Compliant Standard Peripheral Firmware Driver Library documentation.

class robovero.lpc17xx_pwm.PWM_CAPTURECFG_Type(**kwargs)

Bases: robovero.internals.cstruct

PWM Capture Input configuration structure.

  • CaptureChannel: Capture channel, should be in range from 0..1

  • RisingEdge: caption rising edge, should be:

    • ENABLE: Enable rising edge.
    • DISABLE: Disable this function.
  • FallingEdge: caption falling edge, should be:

    • ENABLE: Enable falling edge.
    • DISABLE: Disable this function.
  • IntOnCaption: Interrupt On caption, should be:

    • ENABLE: Enable interrupt function.
    • DISABLE: Disable this function.
  • ptr: LPC1769 memory address where structure is stored. Use this in place of

    the C reference operator (&).

class robovero.lpc17xx_pwm.PWM_CHANNEL_EDGE_OPT

PWM operating mode options.

  • PWM_CHANNEL_SINGLE_EDGE: PWM Channel Single edge mode
  • PWM_CHANNEL_DUAL_EDGE: PWM Channel Dual edge mode
PWM_CHANNEL_DUAL_EDGE = 1
PWM_CHANNEL_SINGLE_EDGE = 0
class robovero.lpc17xx_pwm.PWM_COUNTERCFG_Type(**kwargs)

Bases: robovero.internals.cstruct

Configuration structure in PWM COUNTER mode.

  • CounterOption: Counter Option, should be:

    • PWM_COUNTER_RISING: Rising Edge
    • PWM_COUNTER_FALLING: Falling Edge
    • PWM_COUNTER_ANY: Both rising and falling mode
  • CountInputSelect: Counter input select, should be:

    • PWM_COUNTER_PCAP1_0: PWM Counter input selected is PCAP1.0 pin
    • PWM_COUNTER_PCAP1_1: PWM Counter input selected is PCAP1.1 pin
  • ptr: LPC1769 memory address where structure is stored. Use this in place of

    the C reference operator (&).

class robovero.lpc17xx_pwm.PWM_COUNTER_EDGE_OPT

PWM Input Edge Option in counter mode.

  • PWM_COUNTER_RISING: Rising edge mode
  • PWM_COUNTER_FALLING: Falling edge mode
  • PWM_COUNTER_ANY: Both rising and falling mode
PWM_COUNTER_ANY = 3
PWM_COUNTER_FALLING = 2
PWM_COUNTER_RISING = 1
class robovero.lpc17xx_pwm.PWM_COUNTER_INPUTSEL_OPT

PWM Input Select in counter mode.

  • PWM_COUNTER_PCAP1_0: PWM Counter input selected is PCAP1.0 pin
  • PWM_COUNTER_PCAP1_1: PWM counter input selected is CAP1.1 pin
PWM_COUNTER_PCAP1_0 = 0
PWM_COUNTER_PCAP1_1 = 1
robovero.lpc17xx_pwm.PWM_ChannelCmd(PWMx, PWMChannel, NewState)

Enable/Disable PWM channel output.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
  • PWMChannel: PWM channel, should be in range from 1 to 6
  • NewState: New State of this function, should be:
    • ENABLE: Enable this PWM channel output
    • DISABLE: Disable this PWM channel output
robovero.lpc17xx_pwm.PWM_ChannelConfig(PWMx, PWMChannel, ModeOption)

Configure Edge mode for each PWM channel.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
  • PWMChannel: PWM channel, should be in range from 2 to 6
  • ModeOption: ModeOption PWM mode option, should be:
    • PWM_CHANNEL_SINGLE_EDGE: Single Edge mode
    • PWM_CHANNEL_DUAL_EDGE: Dual Edge mode
robovero.lpc17xx_pwm.PWM_ClearIntPending(PWMx, IntFlag)

Clear specified PWM Interrupt pending.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
  • IntFlag: PWM interrupt flag, should be:
    • PWM_INTSTAT_MR0: Interrupt flag for PWM match channel 0
    • PWM_INTSTAT_MR1: Interrupt flag for PWM match channel 1
    • PWM_INTSTAT_MR2: Interrupt flag for PWM match channel 2
    • PWM_INTSTAT_MR3: Interrupt flag for PWM match channel 3
    • PWM_INTSTAT_MR4: Interrupt flag for PWM match channel 4
    • PWM_INTSTAT_MR5: Interrupt flag for PWM match channel 5
    • PWM_INTSTAT_MR6: Interrupt flag for PWM match channel 6
    • PWM_INTSTAT_CAP0: Interrupt flag for capture input 0
    • PWM_INTSTAT_CAP1: Interrupt flag for capture input 1
robovero.lpc17xx_pwm.PWM_Cmd(PWMx, NewState)

Enable/Disable PWM peripheral.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
  • NewState: New State of this function, should be:
    • ENABLE: Enable Counter in PWM peripheral
    • DISABLE: Disable Counter in PWM peripheral
robovero.lpc17xx_pwm.PWM_ConfigCapture(PWMx, PWM_CaptureConfigStruct)

Configures capture input for PWM peripheral.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1

  • PWM_CaptureConfigStruct: Pointer to a PWM_CAPTURECFG_Type structure that

    contains the configuration information for the specified PWM capture input function.

robovero.lpc17xx_pwm.PWM_ConfigMatch(PWMx, PWM_MatchConfigStruct)

Configures match for PWM peripheral.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1

  • PWM_MatchConfigStruct: Pointer to a PWM_MATCHCFG_Type structure that contains

    the configuration information for the specified PWM match function.

robovero.lpc17xx_pwm.PWM_ConfigStructInit(PWMTimerCounterMode, PWM_InitStruct)

Fills each PWM_InitStruct member with its default value.

If PWMCounterMode = PWM_MODE_TIMER: - PrescaleOption = PWM_TIMER_PRESCALE_USVAL - PrescaleValue = 1 If PWMCounterMode = PWM_MODE_COUNTER: - CountInputSelect = PWM_COUNTER_PCAP1_0 - CounterOption = PWM_COUNTER_RISING

Args:

  • PWMTimerCounterMode: Timer or Counter mode, should be:

    • PWM_MODE_TIMER: Counter of PWM peripheral is in Timer mode
    • PWM_MODE_COUNTER: Counter of PWM peripheral is in Counter mode
  • PWM_InitStruct: Pointer to structure (PWM_TIMERCFG_Type or

    PWM_COUNTERCFG_Type) which will be initialized.

robovero.lpc17xx_pwm.PWM_CounterCmd(PWMx, NewState)

Enable/Disable Counter in PWM peripheral.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
  • NewState: New State of this function, should be:
    • ENABLE: Enable Counter in PWM peripheral
    • DISABLE: Disable Counter in PWM peripheral
robovero.lpc17xx_pwm.PWM_DeInit(PWMx)

De-initializes the PWM peripheral registers to their default reset values.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
robovero.lpc17xx_pwm.PWM_GetCaptureValue(PWMx, CaptureChannel)

Read value of capture register PWM peripheral.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
  • CaptureChannel: capture channel number, should be in range 0 to 1

Return: Value of capture register

robovero.lpc17xx_pwm.PWM_GetIntStatus(PWMx, IntFlag)

Check whether specified interrupt flag in PWM is set or not.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
  • IntFlag: PWM interrupt flag, should be:
    • PWM_INTSTAT_MR0: Interrupt flag for PWM match channel 0
    • PWM_INTSTAT_MR1: Interrupt flag for PWM match channel 1
    • PWM_INTSTAT_MR2: Interrupt flag for PWM match channel 2
    • PWM_INTSTAT_MR3: Interrupt flag for PWM match channel 3
    • PWM_INTSTAT_MR4: Interrupt flag for PWM match channel 4
    • PWM_INTSTAT_MR5: Interrupt flag for PWM match channel 5
    • PWM_INTSTAT_MR6: Interrupt flag for PWM match channel 6
    • PWM_INTSTAT_CAP0: Interrupt flag for capture input 0
  • PWM_INTSTAT_CAP1: Interrupt flag for capture input 1

Return: New State of PWM interrupt flag (SET or RESET)

class robovero.lpc17xx_pwm.PWM_INTSTAT_TYPE

PWM Interrupt status type.

  • PWM_INTSTAT_MR0: Interrupt flag for PWM match channel 0
  • PWM_INTSTAT_MR1: Interrupt flag for PWM match channel 1
  • PWM_INTSTAT_MR2: Interrupt flag for PWM match channel 2
  • PWM_INTSTAT_MR3: Interrupt flag for PWM match channel 3
  • PWM_INTSTAT_CAP0: Interrupt flag for capture input 0
  • PWM_INTSTAT_CAP1: Interrupt flag for capture input 1
  • PWM_INTSTAT_MR4: Interrupt flag for PWM match channel 4
  • PWM_INTSTAT_MR6: Interrupt flag for PWM match channel 5
  • PWM_INTSTAT_MR5: Interrupt flag for PWM match channel 6
PWM_INTSTAT_CAP0 = 16
PWM_INTSTAT_CAP1 = 32
PWM_INTSTAT_MR0 = 1
PWM_INTSTAT_MR1 = 2
PWM_INTSTAT_MR2 = 4
PWM_INTSTAT_MR3 = 8
PWM_INTSTAT_MR4 = 256
PWM_INTSTAT_MR5 = 1024
PWM_INTSTAT_MR6 = 512
robovero.lpc17xx_pwm.PWM_IR_PWMCAPn(n)

Interrupt flag for capture input.

robovero.lpc17xx_pwm.PWM_IR_PWMMRn(n)

Interrupt flag for PWM match channel for 6 channel.

robovero.lpc17xx_pwm.PWM_Init(PWMx, PWMTimerCounterMode, PWM_ConfigStruct)

Initializes the PWMx peripheral corresponding to the specified parameters in the PWM_ConfigStruct.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1

  • PWMTimerCounterMode: Timer or Counter mode, should be:

    • PWM_MODE_TIMER: Counter of PWM peripheral is in Timer mode
    • PWM_MODE_COUNTER: Counter of PWM peripheral is in Counter mode
  • PWM_ConfigStruct: Pointer to structure (PWM_TIMERCFG_Type or

    PWM_COUNTERCFG_Type) which will be initialized.

class robovero.lpc17xx_pwm.PWM_MATCHCFG_Type(**kwargs)

Bases: robovero.internals.cstruct

PWM Match channel configuration structure.

  • MatchChannel: Match channel, should be in range from 0..6

  • IntOnMatch: Interrupt On match, should be:

    • ENABLE: Enable this function.
    • DISABLE: Disable this function.
  • StopOnMatch: Stop On match, should be:

    • ENABLE: Enable this function.
    • DISABLE: Disable this function.
  • ResetOnMatch: Reset On match, should be:

    • ENABLE: Enable this function.
    • DISABLE: Disable this function.
  • ptr: LPC1769 memory address where structure is stored. Use this in place of

    the C reference operator (&).

class robovero.lpc17xx_pwm.PWM_MATCH_UPDATE_OPT

PWM update type.

  • PWM_MATCH_UPDATE_NOW: PWM Match Channel Update Now

  • PWM_MATCH_UPDATE_NEXT_RST: PWM Match Channel Update on next PWM Counter

    resetting

PWM_MATCH_UPDATE_NEXT_RST = 1
PWM_MATCH_UPDATE_NOW = 0
robovero.lpc17xx_pwm.PWM_MatchUpdate(PWMx, MatchChannel, MatchValue, UpdateType)

Update value for each PWM channel with update type option.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
  • MatchChannel: Match channel
  • MatchValue: Match value
  • UpdateType: Type of Update, should be:
    • PWM_MATCH_UPDATE_NOW: The update value will be updated for this channel immediately
    • PWM_MATCH_UPDATE_NEXT_RST: The update value will be updated for this channel on next reset by a PWM Match event.
robovero.lpc17xx_pwm.PWM_ResetCounter(PWMx)

Reset Counter in PWM peripheral.

Args:

  • PWMx: PWM peripheral, should be LPC_PWM1
class robovero.lpc17xx_pwm.PWM_TC_MODE_OPT

PMW TC mode select option.

  • PWM_MODE_TIMER: PWM using Timer mode
  • PWM_MODE_COUNTER: PWM using Counter mode
PWM_MODE_COUNTER = 1
PWM_MODE_TIMER = 0
class robovero.lpc17xx_pwm.PWM_TIMERCFG_Type(**kwargs)

Bases: robovero.internals.cstruct

Configuration structure in PWM TIMER mode.

  • PrescaleOption: Prescale option, should be:

    • PWM_TIMER_PRESCALE_TICKVAL: Prescale in absolute value
    • PWM_TIMER_PRESCALE_USVAL: Prescale in microsecond value
  • PrescaleValue: Prescale value, 32-bit long, should be matched with

    PrescaleOption

  • ptr: LPC1769 memory address where structure is stored. Use this in place of

    the C reference operator (&).

class robovero.lpc17xx_pwm.PWM_TIMER_PRESCALE_OPT

PWM Timer/Counter prescale option.

  • PWM_TIMER_PRESCALE_TICKVAL: Prescale in absolute value
  • PWM_TIMER_PRESCALE_USVAL: Prescale in microsecond value
PWM_TIMER_PRESCALE_TICKVAL = 0
PWM_TIMER_PRESCALE_USVAL = 1