|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
21 #define NCO_PWM_1 0b00100 << 26
24 void pwm2chDriver(
void *par);
29 device = (
void *) malloc(
sizeof(
pwm2ch));
31 device->tCycle = cycleMicroseconds * (
CLKFREQ / 1000000);
34 device->pwm2cog =
cogstart(pwm2chDriver, device, device->pwm2stack,
sizeof(device->pwm2stack)) + 1;
66 if(device->pwm2cog)
cogstop(device->pwm2cog - 1);
71 void pwm2chDriver(
void *par)
77 unsigned int dt = device->tCycle;
83 if(device->ctra !=
CTRA)
87 device->pin =
CTRA & 0b111111;
88 DIRA &= ~(1 << device->pin);
93 device->pin =
CTRA & 0b111111;
94 DIRA |= (1 << device->pin);
98 if(device->ctrb !=
CTRB)
102 device->pin =
CTRB & 0b111111;
103 DIRA &= ~(1 << device->pin);
106 if(device->ctrb != 0)
108 device->pin =
CTRB & 0b111111;
109 DIRA |= (1 << device->pin);
112 PHSA = -device->ticksA;
113 PHSB = -device->ticksB;
#define PHSB
Counter B phase accumulation register.
void pwm2ch_set(pwm2ch *device, int pin, int channel, int tHigh)
Set a PWM signal's high time.
#define PHSA
Counter A phase accumulation register.
Functions for up to 2 channels per cog of PWM signals. More than one cog may be launched,...
#define FRQA
Counter A frequency register.
pwm2ch * pwm2ch_start(unsigned int cycleMicroseconds)
Start PWM process in another cog.
#define FRQB
Counter B frequency register.
#define CLKFREQ
Returns the current clock frequency.
#define CTRB
Counter B control register.
void pwm2ch_stop(pwm2ch *device)
Shut down pwm2ch process and reclaim cog and I/O pins for other uses.
#define waitcnt(a)
Wait until system counter reaches a value.
#define cogstop(a)
Stop a COG.
#define CNT
The system clock count.
#define DIRA
Use to set pins to input (0) or output (1).
int cogstart(void(*func)(void *), void *par, void *stack, size_t stacksize)
Start a new propeller LMM function/thread in another COG.
#define CTRA
Counter A control register.