I at the moment struggling to get a PWM output from my timer1.
The frequency of the PWM signal should be be changeable, such that after a desired amount of time will the frequency be increased to a new value and so on…
I am interfacing the timer1 with the help of the arduino library.
First of all is the problem that i can’t get an pwm out at all.
It seems like when i call Timer1.pwm(), are period = 0 and value = 0?
void TimerOne::pwm(char pin, int duty, long microseconds) // expects duty cycle to be 10 bit (1024)
{
if(microseconds > 0) setPeriod(microseconds);
if(pin == 1 || pin == 9) {
DDRB |= _BV(PORTB1); // sets data direction register for pwm output pin
TCCR1A |= _BV(COM1A1); // activates the output pin
}
else if(pin == 2 || pin == 10) {
DDRB |= _BV(PORTB2);
TCCR1A |= _BV(COM1B1);
}
setPwmDuty(pin, duty);
resume(); // Lex - make sure the clock is running. We don't want to restart the count, in case we are starting the second WGM
// and the first one is in the middle of a cycle
}
What could be wrong here ? the interrupt was suppose to change the frequency of the PWM, as well as changing the timespan between the interrupts?.. I am doing something wrong here?
Based on the table the python code generates, it doesn't seem like that it is nessesary to change the prescaler but just just the OCR1AH/L register... is that correct understood?
Lets try this a different way…
I convinced myself that using the library doesn’t make me any better, so choose to set it up myself.
And i am still stuck…
Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.
This thread locked. It is a bit annoying to see you spraying your questions everywhere. Rather than get better answers you get fragmented ones, as people don't see the whole project. And then when they see what you are doing they get annoyed.