PWM beim XMEGA

Gast #3054538
Lesenswert?

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
#3054546
Lesenswert?

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.
Gast #3054549
Lesenswert?

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
Gast #3054567
Lesenswert?

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.
#3054585
Lesenswert?

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.

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