Forum: Mikrocontroller und Digitale Elektronik Timer0 Interrupt mit Xmega128A1


von R--- S. (rene66)


Lesenswert?

Hallo,

hebe gerade versucht mit einem Xmega in Simulator einen Timer Overfolw
hinzubekommen.

mit

ldi temp,0x01
sts TCC0_CTRLA,temp
ldi temp,0x0F
sts TCC0_INTCTRLA,temp
sei


geht auch im Simulator werden die Flags bei Overflow gesetzt aber der 
Interrupt wird nicht ausgelöst bzw es springt nicht zum Overfolw vector.

Muß ich irgendwo nochwas einstellen ich denke sei reicht wohl nicht mehr 
und es sind irgendwo noch andere Flags zu setzten.

von Knut B. (Firma: TravelRec.) (travelrec) Benutzerseite


Lesenswert?

Der Interrupt Controller muß initialisiert werden.

von R--- S. (rene66)


Lesenswert?

zum Verständnis mache ich das im Reset per asm?

16Bit Register lesen geht schon

lds temph,TCC0_CNT
lds templ,TCC0_TEMP ;

aber mit dem Schreiben in die Register habe ich so mein Problem

sts TCC0_CNT,temph
sts TCC0_TEMP,templ

von Knut B. (Firma: TravelRec.) (travelrec) Benutzerseite


Lesenswert?

>zum Verständnis mache ich das im Reset per asm?

Wie bitte?

>lds temph,TCC0_CNT
>lds templ,TCC0_TEMP ;

so wär´s richtig:

lds tempL, TCC0_CNT
lds tempH, TCC0_CNT+1

sts TCC0_CNT, tempL
sts TCC0_CNT+1, tempH

XMegas lesen und schreiben LOW vor HIGH.

von R--- S. (rene66)


Lesenswert?

danke für die info

aber wie und wo mache ich die Configuration

ich habe z.B. versucht was in

ldi temp,0x40
sts PMIC_STATUS,temp

das IRC Register nach dem Reset was zu schreiben da tut sich aber nix

wenn ich statt sts out schreibe gibt es eine Fehlermeldung vom Studio.

von Knut B. (Firma: TravelRec.) (travelrec) Benutzerseite


Lesenswert?

Das muß in PMIC_CTRL.

ldi  Temp, 0b00000111
sts  PMIC_CTRL, Temp

schaltet alle 3 Interruptprioritäten frei. Ach und das 'SEI' zum 
Einschalten der globalen Interruptfreigabe nicht vergessen.

von R--- S. (rene66)


Lesenswert?

Danke das geht jetzt auch.
jetzt fehlen nur noch die IR vector Adressen

von Knut B. (Firma: TravelRec.) (travelrec) Benutzerseite


Lesenswert?

So, das andere machst Du aber selber.


.org $0000
 jmp  RESET          ;Reset
 jmp  RESET          ;NMI, ext. osc. failure
 jmp  RESET          ;PortC Int0
 jmp  RESET          ;PortC Int1
 jmp  RESET          ;PortR Int0
 jmp  RESET          ;PortR Int1
 jmp  RESET          ;DMA Channel0
 jmp  RESET          ;DMA Channel1
 jmp  RESET          ;DMA Channel2
 jmp  RESET          ;DMA Channel3
 jmp  RESET          ;RTC Overflow
 jmp  RESET          ;RTC Compare
 jmp  RESET          ;TWI_C Slave
 jmp  RESET          ;TWI_C Master
 jmp  RESET          ;Timer_C0 Overflow
 jmp  RESET          ;Timer_C0 Error
 jmp  RESET          ;Timer_C0 Compare/CaptureA
 jmp  RESET          ;Timer_C0 Compare/CaptureB
 jmp  RESET          ;Timer_C0 Compare/CaptureC
 jmp  RESET          ;Timer_C0 Compare/CaptureD
 jmp  RESET          ;Timer_C1 Overflow
 jmp  RESET          ;Timer_C1 Error
 jmp  RESET          ;Timer_C1 Compare/CaptureA
 jmp  RESET          ;Timer_C1 Compare/CaptureB
 jmp  RESET          ;SPI_C Complete
 jmp  RESET          ;USART_C0 RXComplete
 jmp  RESET          ;USART_C0 DataRegisterEmpty
 jmp  RESET          ;USART_C0 TXComplete
 jmp  RESET          ;USART_C1 RXComplete
 jmp  RESET          ;USART_C1 DataRegisterEmpty
 jmp  RESET          ;USART_C1 TXComplete
 jmp  RESET          ;AES
 jmp  RESET          ;NVM EE ready
 jmp  RESET          ;NVM SPM ready
 jmp  RESET          ;PortB Int0
 jmp  RESET          ;PortB Int1
 jmp  RESET          ;AC_B Int0
 jmp  RESET          ;AC_B Int1
 jmp  RESET          ;AC_B WindowInt
 jmp  RESET          ;ADC_B Channel0
 jmp  RESET          ;ADC_B Channel1
 jmp  RESET          ;ADC_B Channel2
 jmp  RESET          ;ADC_B Channel3
 jmp  RESET          ;PortE Int0
 jmp  RESET          ;PortE Int1
 jmp  RESET          ;TWI_E Slave
 jmp  RESET          ;TWI_E Master
 jmp  RESET          ;Timer_E0 Overflow
 jmp  RESET          ;Timer_E0 Error
 jmp  RESET          ;Timer_E0 Compare/CaptureA
 jmp  RESET          ;Timer_E0 Compare/CaptureB
 jmp  RESET          ;Timer_E0 Compare/CaptureC
 jmp  RESET          ;Timer_E0 Compare/CaptureD
 jmp  RESET          ;Timer_E1 Overflow
 jmp  RESET          ;Timer_E1 Error
 jmp  RESET          ;Timer_E1 Compare/CaptureA
 jmp  RESET          ;Timer_E1 Compare/CaptureB
 jmp  RESET          ;SPI_E Complete
 jmp  RESET          ;USART_E0 RXComplete
 jmp  RESET          ;USART_E0 DataRegisterEmpty
 jmp  RESET          ;USART_E0 TXComplete
 jmp  RESET          ;USART_E1 RXComplete
 jmp  RESET          ;USART_E1 DataRegisterEmpty
 jmp  RESET          ;USART_E1 TXComplete
 jmp  RESET          ;PortD Int0
 jmp  RESET          ;PortD Int1
 jmp  RESET          ;PortA Int0
 jmp  RESET          ;PortA Int1
 jmp  RESET          ;AC_A Int0
 jmp  RESET          ;AC_A Int1
 jmp  RESET          ;AC_A WindowInt
 jmp  RESET          ;ADC_A Channel0
 jmp  RESET          ;ADC_A Channel1
 jmp  RESET          ;ADC_A Channel2
 jmp  RESET          ;ADC_A Channel3
 jmp  RESET          ;TWI_D Slave
 jmp  RESET          ;TWI_D Master
 jmp  RESET          ;Timer_D0 Overflow
 jmp  RESET          ;Timer_D0 Error
 jmp  RESET          ;Timer_D0 Compare/CaptureA
 jmp  RESET          ;Timer_D0 Compare/CaptureB
 jmp  RESET          ;Timer_D0 Compare/CaptureC
 jmp  RESET          ;Timer_D0 Compare/CaptureD
 jmp  RESET          ;Timer_D1 Overflow
 jmp  RESET          ;Timer_D1 Error
 jmp  RESET          ;Timer_D1 Compare/CaptureA
 jmp  RESET          ;Timer_D1 Compare/CaptureB
 jmp  RESET          ;SPI_D Complete
 jmp  RESET          ;USART_D0 RXComplete
 jmp  RESET          ;USART_D0 DataRegisterEmpty
 jmp  RESET          ;USART_D0 TXComplete
 jmp  RESET          ;USART_D1 RXComplete
 jmp  RESET          ;USART_D1 DataRegisterEmpty
 jmp  RESET          ;USART_D1 TXComplete
 jmp  RESET          ;PortQ Int0
 jmp  RESET          ;PortQ Int1
 jmp  RESET          ;PortH Int0
 jmp  RESET          ;PortH Int1
 jmp  RESET          ;PortJ Int0
 jmp  RESET          ;PortJ Int1
 jmp  RESET          ;PortK Int0
 jmp  RESET          ;PortK Int1
 jmp  RESET          ;Reserved
 jmp  RESET          ;Reserved
 jmp  RESET          ;PortF Int0
 jmp  RESET          ;PortF Int1
 jmp  RESET          ;TWI_F Slave
 jmp  RESET          ;TWI_F Master
 jmp  RESET          ;Timer_F0 Overflow
 jmp  RESET          ;Timer_F0 Error
 jmp  RESET          ;Timer_F0 Compare/CaptureA
 jmp  RESET          ;Timer_F0 Compare/CaptureB
 jmp  RESET          ;Timer_F0 Compare/CaptureC
 jmp  RESET          ;Timer_F0 Compare/CaptureD
 jmp  RESET          ;Timer_F1 Overflow
 jmp  RESET          ;Timer_F1 Error
 jmp  RESET          ;Timer_F1 Compare/CaptureA
 jmp  RESET          ;Timer_F1 Compare/CaptureB
 jmp  RESET          ;SPI_F Complete
 jmp  RESET          ;USART_F0 RXComplete
 jmp  RESET          ;USART_F0 DataRegisterEmpty
 jmp  RESET          ;USART_F0 TXComplete
 jmp  RESET          ;USART_F1 RXComplete
 jmp  RESET          ;USART_F1 DataRegisterEmpty
 jmp  RESET          ;USART_F1 TXComplete


;Program-Code starts here
RESET:

von R--- S. (rene66)


Lesenswert?

Ich Danke Dir sehr.
hat was gut bei mir.

von R--- S. (rene66)


Lesenswert?

Hallo,

noch eine Frage.

wenn wenn ich aus dem Timer overfolw Interrupt mit Reti komme wird das 
overflow Flag nicht zurückgesetzt gibt es da auch noch eine Einstellung 
für das die Flags nach dem Reti automatisch zurückgesetzt werden oder 
muß man das jetzt per Software machen?

von Knut B. (Firma: TravelRec.) (travelrec) Benutzerseite


Lesenswert?

Das Flag wird zurückgesetzt. Es kann höchstens sein, daß es schon 
wieder einen Obverflow gab, bevor Deine ISR zuende ist.

von R--- S. (rene66)


Lesenswert?

Hallo,

geht es lag am AVR Studio ich habe das jetzt nochmal auf einem anderen 
Rechner Probiert und da geht es. Irgendwas stimmt nicht mit er 
Installation auf dem Rechner nicht jedesmal wenn ich einen Step klicke 
dann dauert es ca 1 Sekunde bis zum nächsten und der Rechner fährt auf 
100% Systemauslastung da stimmt was nicht.

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
Noch kein Account? Hier anmelden.