Hallo Leute,
Ich versuche jetzt eine 100KHz PWM mit meinen Attiny26 zu generieren.
Ich bekomme leider am 0C1B (PB3 Pin) gar keine PWM und habe schon
mehrmals kontroliert und findet bisher den Fehler nicht. Ich benutze die
interne Oszillatorfrequenz.
Könnten Sie bitte mir weiterhelfen!! hier mein Code
danke im voraus
1 | #include <avr/io.h>
|
2 | #include <avr/interrupt.h>
|
3 |
|
4 |
|
5 | void pwm_init()
|
6 | {
|
7 | TCCR1A |= ((1<<COM1B1)|(1<<PWM1B)); //clear OCR1B on compare macht and pwm mode enable
|
8 | TCCR1B |= ((1<<CTC1)|(1<<CS10)); // CTC mode enable (clear timer on compare match OCR1C OCR1A gibt den dutycycle an) and clock the timer withough prescaller (so we can have enough levels for the duty cycle)
|
9 | TCNT1 = 0;
|
10 | OCR1B = 45; // controliert die dusty
|
11 | OCR1C = 59; // controliert die Frequenz
|
12 | TIMSK|= (1<<OCIE1B); // Timer/counter output compare match with OCR1B interrupt enable
|
13 | sei(); // Timer/counter global interrupt enable
|
14 | }
|
15 |
|
16 |
|
17 | int main(void)
|
18 | {
|
19 | DDRB |= (1<<PB3); // als Ausgang gesetzt das ist der OC1B PIN für PWM
|
20 |
|
21 |
|
22 |
|
23 | while(1)
|
24 | {
|
25 |
|
26 | }
|
27 | }
|
MFG
Sixafeud