MityDSP Documentation Index
tcDspPwm

Introduction

The tcDspPwm class may be used to provide access to a single PWM core. Each instance of DspPwm provides access to as many as 5 configurable pulse outputs, and installs an ISR at the Core interrupt level in order to report completions of fixed cycle (or one shot) pulse outputs, when enabled.

When created, the constructor requires a valid base address for the PWM core. Optionally, the user may provide a pointer to a tcDspPwmConfig structure to provide pulse initialization parameters. This structure is not referenced (and may be deleted or freed) after initialization. The PWM core is not enabled after construction. The Enable() method must be called at least once to enable the outputs.

Each pulse may be configured to have a fixed initial delay from a trigger event, then have a continuous period with a fixed OnTime (which occurs at the beginning of the defined period). The configuration method is ConfigurePulse(). Note that the OnTime must not exceed the total period time. Each of the 5 pulse outputs maybe enabled/disabled using the EnablePulse() Command.

There is no limit to the number of instances of tcDspPwm that may be created, aside from the design of the FPGA module.

Note: PWM class is not thread safe. It is assumed that only one controlling thread will access any one PWM object. If multi-thread access is required, the application must provide serialization interlocks.

See also:
MityDSP::tcDspPwm Class Reference

Example

This is a simple example of tcDspPwm creation and usage:

{
unsigned int values;
unsigned int my_base_addr = 0xB0000018;
tcDspPwm *my_pwm;
tcDspPwmConfig my_config;
// Set up Desired configuration....
// Input Clock is 25 Mhz.
//
// Enable the first 2 pulses
// Pulse 1 - delay 30 usecs from trigger, generate
1 Khz pulse train using a 1 usec pulse width.
// Pulse 2 - delay 35 usecs from trigger, generate
1 Khz pulse train using a 10 usec pulse width.
// Use external triggering
my_config.mnDivisorClocks = 25; // divide 25 Mhz by 25 yields 1 usec increments
my_config.mbPulseEnables[1] = true; // pulse 0 is enabled and all others default to off, turn on [1]
my_config.mnPulseDelay[0] = 30; // 30 usecs
my_config.mnPulsePeriod[0] = 1000; // 1000 usecs -> 1 ms -> 1 Khz
my_config.mnPulseOnTime[0] = 1; // 1 usec
my_config.mnPulseDelay[1] = 35; // 35 usecs
my_config.mnPulsePeriod[1] = 1000; // 1000 usecs -> 1 ms -> 1 Khz
my_config.mnPulseOnTime[1] = 10; // 10 usec
// create a GPIO interface
my_pwm = new tcDspPwm((void *)my_base_addr, &my_config);
// Enable the PWM, pulses will start once a trigger pulse is received
my_pwm->Enable(true);
...
}

  
Generated on Mon Apr 22 2013 11:33:02 for MityDSP Core by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.