PWM mit Tiny26

Gast #138432
Lesenswert?

Hallo Georg,
Ich hatte bis gerade eben noch das selbe Problem.
Hier ist der Quelltext für die Initialisierung eines
250kHz PWM-Signals mit Bascom:

'tiny26 Fast-PWM (250kHz) an OC1a

Config Pinb.1 = Output
Set $29.1
Waitms 120
Set $29.2                                                   '-> PLL
64MHz ; reset für synchronous clock
Set Tccr1a.com1a0
Set Tccr1a.pwm1a

Ocr1c = 255

Set Tccr1b.ctc1
Set Tccr1b.cs10

Ocr1a = 20

End


Du müsstest es dann eben noch entsprechend ändern, die Teiler und die
Taktquelle anpassen.
Ich hoffe, ich konnte Dir weiterhelfen.

Gruß
Stefan
Gast #138433
Lesenswert?

Quick and Dirty, kleine Anpassungen evtl. noch nötig:

PLLCSR = 1<<PLLE;                  // PLL einschalten
while (!( PLLCSR & (1<<PLOCK) ));  // Warten bis PLL gelockt ist
PLLCSR = (1<<PLLE) + (1<<PCKE);    // PLL freigeben

OCR1A = 0x4E;
OCR1C = 0xC2;

TCCR1A = (1<<COM1A0) + (1<<PWM1A);
TCCR1B = 0x0B | (1<<CTC1);         // 0x0B im Datasheet kontrolieren!

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren