Component: PWM (CAL) (Peripheral CAL)

From Flowcode Help
Jump to navigationJump to search


Author Matrix TSL
Version 2.0 (Release)
Category Peripheral CAL


Image PWM (CAL) component

CAL = Code Abstraction Layer - Allows one code base to run on a wide range of chips. A low level implementation giving direct access to the Pulse Width Modulation peripheral.


Examples

Example showing how to build a component using a CAL component Using CAL Components.


Downloadable macro reference

ChangePeriod

Change the Period (and prescaler) for this PWM Channel

Parameters

UINT period
period value PIC/AVR: 0-255 16-bit PIC: 0-65535
UINT prescaler
prescaler 1,4,16,64


Return value

This call does not return a value


Disable

Disable this PWM Channel

Parameters

This macro has no parameters


Return value

This call does not return a value


SetDuty8Bit

Set the Duty cycle (0-255) for this PWM Channel

Parameters

BYTE duty
duty value 0 - 255


Return value

This call does not return a value


Enable

Enable this PWM Channel

Parameters

This macro has no parameters


Return value

This call does not return a value


SetDuty10Bit

Set the Duty Cycle for this PWM Channel.

PIC/AVR - Range: 0-1023

16-bit PIC - Range: 0-65535

Parameters

UINT duty
Duty value 0 - 1023


Return value

This call does not return a value


Simulation macro reference

GetValue

Returns Named property Value

Parameters

STRING Name


Return value

STRING


SetValue

Sets the Value of the property

PERIOD, PRESCALE or CHANNEL

(if CHANNEL also updates the PORT from FCD)

Parameters

STRING Name
STRING Value


Return value

This call does not return a value


GetList

Returns CHANNEL or PRESCALE list from the FCD

and updates the internal property

Parameters

STRING Name


Return value

STRING



Property reference

Channel

This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.

PWM Channel selector

Alt Pin Enable

This property is of type Fixed list of ints and can be referenced with the variable name HWALT.

Alternative Pin Enable (if available on target device)

Port

This property is of type Single digital pin and can be referenced with the variable name PORT.

No additional information


Period Register

This property is of type Signed integer and can be referenced with the variable name PERIOD.

PWM Period Register value

Prescaler Divide

This property is of type Fixed list of ints and can be referenced with the variable name PRESCALE.

Prescaler Divider value

PWM Timer

This property is of type Fixed list of ints and can be referenced with the variable name timer.

Timer associated with PWM to drive the output.

Warning - All PWM channels linked to the same timer will share the same period and prescaler settings.

Clock Speed

This property is of type Signed integer and can be referenced with the variable name CLK_SPEED.

No additional information


Period (uS)

This property is of type Floating point and can be referenced with the variable name CALC_PERIOD.

No additional information


Frequency (KHz)

This property is of type Floating point and can be referenced with the variable name CALC_FREQ.

No additional information


Frequency (Hz)

This property is of type Floating point and can be referenced with the variable name CALC_FREQ2.

No additional information


Master Divider

This property is of type Signed integer and can be referenced with the variable name master_divider.

No additional information