0

I'm working with the latest rev of the Arduino TimerOne Library.

If I do NOT use the TimerOne.attachinterrupt(xxx) function, Pin 10 generates a proper PWM signal per supplied parameters.

When I call TimerOne.Attachinterrupt(isr,frequency) or just ...(isr) the call never 'returns' - ie the signal on Pin 10 does not start, the loop doesn't get entered. I turn on an LED before call the attach, then turn it off in the next line - but the LED never goes off.

The ISR only decrements a global volatile variable

It appears the AttachISR is breaking something... Code setup follows:

pinMode(LED,OUTPUT);
digitalWrite(LED,HIGH);
MyTime.attachInterrupt(ISRFUNC,pwmFreq);
digitalWrite(LED,LOW);
MyTime.initialize(pwmFreq);
MyTime.pwm(pwmPin,pwmDC,pwmFreq);
MyTime.start();
opalenzuela
  • 3,139
  • 21
  • 41
Harrzack
  • 3
  • 3
  • Seeing your entire code sketch and a hardware diagram could be helpful, some of this seems like it should go on during the setup part and not the loop, like "pinMode(LED,OUTPUT);" – DrCord Nov 20 '13 at 17:12
  • This is pretty much the whole sketch! I'm just doing some early testing and 'tire-kicking' in my first attempt to run a stepper. I'm using the Easy Driver board, and just have to send a PWM stream to it's step pin. This code is all in setup(). The two LED writes are a lame debug technique. When the interrupt ISR is NOT called, the LED goes on and off. If I try and use the attachISR - the LED goes on but never turns off. To me this means the code never 'returned' from the attachISR func. Have stared at the code in the lib, but can't see any glaring errors... but it IS very pronounced. – Harrzack Nov 20 '13 at 21:05
  • you probably want to be doing some of these things in the looping part of the sketch... – DrCord Nov 20 '13 at 21:15

0 Answers0