17 #include "simpletools.h" 20 #define NCO_PWM_1 0b00100 << 26 24 static unsigned int pwstack[(160 + (50 * 4)) / 4];
26 static volatile unsigned int tCycle, ticksA, ticksB, ctra, ctrb;
34 int pwm_start(
unsigned int cycleMicroseconds)
37 tCycle = cycleMicroseconds * st_usTicks;
38 pwcog = cogstart(pw, NULL, pwstack,
sizeof(pwstack)) + 1;
42 void pwm_set(
int pin,
int channel,
int tHigh)
48 ticksA = tHigh * st_usTicks;
54 ticksB = tHigh * st_usTicks;
60 if(pwcog) cogstop(pwcog - 1);
69 unsigned int dt = tCycle;
78 pin = CTRA & 0b111111;
82 pin = CTRA & 0b111111;
89 pin = CTRB & 0b111111;
93 pin = CTRB & 0b111111;