Hallo Leute, ich möchte bei einem XMEGA einen PWM an einen Pin z.B. PINB0 ausgeben. ich habe den Clock eingestellt mit TCD0.CTRLA = TC_CLKSEL_DIV2_gc; AUßerdem habe ich Peiode mit TCD0.PER = 1000; eingestellt. Über TCD0.CTRLB = TC_WGMODE_SS_gc | TC0_CCAEN_bm; habe ich den Single PWM aktiviert und den Duty Cycle mit CCA eingestellt TCD0.CCA = 500; Jedoch weiß ich nicht wie ich einstellen kann das das PWM Signal am PINB0 oder PINC5 ausgegeben wird. Ich weiß das ich den Pin zuvor auf Ausgang umschalten muss, aber ich weiß nicht wo ich es einstellen kann das das PWM Signal über diesen PIN ausgegeben wird
Sebastian schrieb: > TCD0.CTRLB = TC_WGMODE_SS_gc | TC0_CCAEN_bm TCD0 -> Timer 0 an Port D auf Pins 0 bis 3, TC0_CCAEN_bm -> Timer 0 an Port D Output Compare Kanal A, suche im Datenblatt die alternativen Pinbelegungen vom Port D. Ich würde mit 80% davon ausgehen das das PD0 ist.
Sebastian schrieb: > Jedoch weiß ich nicht wie ich einstellen kann das das PWM Signal am > PINB0 oder PINC5 ausgegeben wird. PINs 0 bis 3 an PORT B werden vom Timer 0 an Port B bedient -> TCB0 -> CCA bis CCD. Pins 4 bis 7 werden durch den Timer 1 -> TCB1 bedient. Pins an Port C durch Timer TCC0 und TCC1. Bei neueren XMegas, du hast uns ja verschwiegen welchen du konkret benutzt, kann man das untere Nibble -> Pin 0 bis 3 mit dem oberen Nibble -> Pin 4 bis 7, vertauscht werden. Das geht über das PORT Mapping Register.
Habe ich das richtig verstanden das beim XMEGA der Timer TCC0 nur für PORT C funktioniert und TCD0 für PORT D und TCE= für PORT E? Das mit TC0_CCAEN_bm -> Timer 0 an Port D Output Compare Kanal A, suche im Datenblatt die alternativen Pinbelegungen vom Port D. Ich würde mit 80% davon ausgehen das das PD0 ist. habe ich nicht verstanden
Ich habe es gefunden :-) Dieses Dokument vom Atmel beschreibt die PWMs besser als das Datenblatt direkt http://www.atmel.com/Images/doc8045.pdf An XMEGA TC module is related to an I/O port through the I/O pins it can control with the output compare module. The naming of the TC modules reflects the I/O port it is connected and the available features for that Timer/Counter. Each TC module has a name that follows the form: TCxn. TC is short for Timer/Counter, x indicates the port it is connected to and n is the TC number within PORTx. As an example, TCD0 is Timer/Counter 0 connected to PORTD. Timers are available on PORTC, PORTD, PORTE or PORTF, if available on device. Timer0 on each port has 4 compare or capture channels, while Timer1 has 2 compare or capture channels. Figure 3-1 shows how the output compare channels are connected to the associated I/O port. Timer0 has its outputs connected to pins 0-3 within the port, while Timer1 is mapped to pins 4 and 5.
Ich benutze den ATXMEGA32A4U Dort gibt es nur den Timer TCC, TCD und TCE. Einen Timer TCB gibt es bei keinem ATXMGEA
Sebastian schrieb: > TC0_CCAEN_bm -> Timer 0 an Port D Output Compare Kanal A, suche im > Datenblatt die alternativen Pinbelegungen vom Port D. Ich würde mit 80% > davon ausgehen das das PD0 ist. > > habe ich nicht verstanden gehe zu: http://www.atmel.com/products/microcontrollers/avr/avr_xmega.aspx?tab=documents lade ATXMega128D4 Complete: http://www.atmel.com/Images/Atmel-8135-8-and-16-bit-AVR-microcontroller-ATxmega16D4-32D4-64D4-128D4_datasheet.pdf Kapitel 28. "Pinout and Pin Function" zB. Tabelle 28.3 auf Seite 51 beschreibt das was du suchst.
Shit für Port_B muss ich eine Interrupt Service Routine nehmen, da für Port_B kein Timer vorhanden ist.
Versuchs doch mal mit dem Event System... dann kannste dir den Interrupt (SoftwarePWM) evtl. schenken...
Basti M. schrieb: > Versuchs doch mal mit dem Event System Das alleine macht den Kohl noch nicht fett, da braucht´s dann auch noch DMA und das jittert...
Beim LED Dimmen wird das wohl nicht auffallen... oder weißt du schon was er vor hat? Also Event System hab ich noch nicht jittern sehen, da nervt bloß der eine Takt Verzögerung unter Umständen =) DMA jittert ja logischerweise weil die CPU Vorrang hat, oder welche Erfahrungen gibts da von deiner Seite?
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.