luni64/EncSim

EncSim disables PWM generation ?

Closed this issue · 1 comments

Hello,

Great work. However, it seems that EncSim disables the PWM generation, am I correct ?

Here is my code:

`// Utilise https://github.com/luni64/EncSim
// et https://github.com/luni64/TeensyDelay

#include <TeensyDelay.h>
#include <EncSim.h>

EncSim<3, 4> simulator; // use pin 3 and pin 4 as output
int32_t i = 0;

const uint8_t pwm_inca = 5;
const uint8_t pwm_incb = 6;
const uint8_t pwm_incc = 9;
const uint8_t pwm_incd = 10;

void setup() {
// Résolution du pwm
analogWriteRes(12);

// Fréquence du pwm (6.25 kHz max)
analogWriteFrequency(pwm_inca, 6000);
analogWriteFrequency(pwm_incb, 6000);
analogWriteFrequency(pwm_incc, 6000);
analogWriteFrequency(pwm_incd, 6000);

// Génération de PWM à rapport cyclique fixe pour tester les sorties analogiques via le LTC2645
analogWrite(pwm_inca, 2048);
analogWrite(pwm_incb, 2048);
analogWrite(pwm_incc, 4095);
analogWrite(pwm_incd, 4095);

simulator.begin();

simulator
.setFrequency(150)          // 150Hz count rate
.setPhase(90)               // normal 90� phase shift
.setTotalBounceDuration(0); // no bouncing

simulator.moveRelAsync(1000000);

}

void loop() {
// if (150 + i10 < 1000000) {
// i+= 10;
// }
// simulator
// .setFrequency(150 + i
10) // (150 + i*10)Hz count rate
// .setPhase(90) // normal 90� phase shift
// .setTotalBounceDuration(0); // no bouncing
//
// simulator.moveRelAsync(1000000);
// delay(10);
}`

Thanks in advance for your answer,

Nicolas

Yes that is true. Internally it uses TeensyDelay which uses one of the FTM timers which also do the PWM.
Here: https://github.com/luni64/TeensyDelay#configuration you find information how to change the used timer and which of the FTM timers is used for which PWM pin.