PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : AVR timer0 Interrupt ?



Import-Script
06.11.2003, 21:11
!!! VERZWEIFEL !!! <BR>ich hab vor mir einen atmega161 der sich strikt weigert, einen timer-int zu starten! <BR> <BR>hier das programm: <BR>;############################################ <BR>.INCLUDE &#34;m161def.inc&#34; <BR> <BR>.def temp1 = r16 <BR>.def timerByte = r19 <BR> <BR>.CSEG <BR>.ORG 0x00 <BR> rjmp RESET ;1 <BR> reti ;2 eint0 <BR> reti ;3 eint1 <BR> reti ;4 eint2 <BR> reti ;5 timer 2 compare match <BR> reti ;6 timer 2 <BR> reti ;7 timer 1 <BR> reti ;8 timer 1 <BR> reti ;9 timer 1 <BR> reti ;10 timer 1 <BR> reti ;11 timer 0 compare match <BR> rjmp TIMER_INT ;12 timer 0 overflow <BR> reti ;13 spi <BR> reti ;14 UART0 <BR> reti ;15 UART1 <BR> reti ;16 UART0 <BR> reti ;17 UART1 <BR> reti ;18 UART0 TXC <BR> reti ;19 UART1 TXC <BR> reti ;20 ee_rdy <BR> reti ;21 ana_comp <BR> <BR>.ORG 0x30 <BR>RESET: <BR>;stack <BR> ldi temp1, low&#40;RAMEND&#41; <BR> out SPL, temp1 ldi temp1, high&#40;RAMEND&#41; out SPH, temp1 <BR>; TIMER 0 <BR>; TCCR0: Clock Select Bits &#40;1:0:1 = prescaler 1024&#41; <BR> ldi temp1, 0b00000101 <BR> out TCCR0, temp1 ; <BR> ldi temp1, 0x02 ;overflow-int enablen <BR> out TIMSK, temp1 <BR> <BR> sei ;general ints enable <BR> <BR> <BR> ser temp1 <BR> out DDRA, temp1 ;als output f&uuml;r leds <BR>testloop: <BR> clr temp1 ;leds einschalten <BR> out PORTA, temp1 <BR> ldi timerByte, 0x80 <BR> <BR>Loop1: <BR> tst timerByte ;solange warten, der timer runtergezählt hat <BR> brne Loop1 <BR> <BR> ser temp1 ;leds ausschalten <BR> out PORTA, temp1 <BR> ldi timerByte, 0x80 <BR> <BR>Loop2: <BR> tst timerByte ;solange warten, der timer runtergezählt hat <BR> brne Loop2 <BR> <BR> rjmp testloop <BR> <BR> <BR> <BR>TIMER_INT: <BR> push temp1 <BR> in temp1, SREG <BR> <BR> dec timerByte <BR> <BR> out SREG, temp1 <BR> pop temp1 <BR> reti <BR> <BR>;################################################ <BR> <BR>hatte den ausschalt-befehl auch schon in der isr, aber ging auch nicht! <BR> <BR>vielen Dank f&uuml;r eure hilfe! <BR>nides <BR> <BR>

Import-Script
06.11.2003, 23:03
hab ganz vergessen zu erklären: <BR> <BR>ich schalte leds an einem port ein. <BR>dann lasse ich den timer einen zähler runterzählen. wenn er 0 wird schalte ich die led wieder aus. nur bis dorthin kommt der avr nicht. <BR>er ruft den timer-interrupt nie auf. <BR> <BR>hab ein einem howto ein &#40;fast&#41; identes programm gefunden, welches auch nicht funktioniert. <BR>

Import-Script
07.11.2003, 07:58
Guckst du in Datenblatt. Auf Seite 23 steht alles. <BR> <BR>Dir ist vielleicht aufgefallen, dass dein Controller mehr als 8kByte Speicher hat? Da reicht dann ein Byte zum Adressieren nicht mehr aus, man braucht zwei. Deshalb solltest du deine Interrupttabelle mit .org-Anweisungen aufbauen. <BR>Dein Timer0Overflow-IRQ steht nämlich nicht an Adresse 0x0B, so wie bei dir, sondern an Adresse 0x16. <BR>Deine Tabelle w&uuml;rde bei jeden AVR bis 8kByte Flash funktionieren, alles, was dr&uuml;ber ist, streikt. <BR> <BR>Deshalb: <BR> <BR>.org TIM0_OVF &#40;oder wie immer das bei dir auch heißt&#41; <BR>jmp Timer0_IRQ_Handler <BR> <BR> <BR>Gruß, ERDI - Soft. <BR> <BR>P.S.: Hoffe, du verstehts, was ich meine. :-&#41; <BR>

Import-Script
07.11.2003, 16:07
ich beisse mir grad in den a&#42;&#42;&#42;&#42; !!! <BR>vielen dank!!!! <BR>ich hatte nicht bedacht, dass der speicher ja in worten und nicht in bytes organisiert ist! <BR> <BR>DANKE !!! <BR> <BR>nides

Import-Script
07.11.2003, 16:10
Lass es dir schmecken: :-&#41; <BR> <BR>Wäre mir mit Sicherheit auch passiert, wenn ich nicht schonmal dar&uuml;ber gelesen hätte. <BR> <BR>Schönes WE.