PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : SIG_OUTPUT_COMPARE1A wird nicht aufgerufen



ricola
03.01.2008, 13:58
hallo,
ich habe da ein kleines problem mit meinem ATmega169. Ich benutze
alle 4 PWM und möchte zusätzlich noch über den ouput compare match
eine funktion func() aufrufen. das signal für den compare match kommt
aber nie....?

die pwm funkionieren tadellos. wenn ich in der initInterrupt allerding
das sei() mit reinnehme, dann erfolt laufend ein reset???



static void initPWM(void) {

// 8bit timer/counter 0
TCCR0A = (1<<WGM00)|(1<<COM0A1)|(1<<CS01);
// set initial pwm
OCR0A = 200;

// 16bit timer/counter 1
TCCR1A = (1<<WGM10)|(1<<COM1A1)|(1<<COM1B1);
TCCR1B = (1<<CS10);
// set initial pwm
OCR1A = 200;
OCR1B = 200;

// 8bit timer/counter 2
TCCR2A = (1<<WGM20)|(1<<COM2A1)|(1<<CS21);
// set initial pwm
OCR2A = 200;
}

static void initInterrupt(void) {

TIMSK1 |= (1<<OCIE1A);
//sei();
}

SIGNAL (SIG_OUTPUT_COMPARE1A) {

func();

}




Danke für Hilfe!

Gruß
RICOLA

askazo
03.01.2008, 14:19
Hm, sieht so weit eigentlich ganz ok aus.

Hast Du vielleicht noch irgendwo anders einen Interrupt aktiviert, zu dem Du noch keine ISR geschrieben hast?

Gruß,
askazo

PicNick
03.01.2008, 14:30
Beim GCC führt jeder nicht belegte ISR-Vector zu einem Reset.
d.h. imho irgendwas passt ihm da nicht


SIGNAL (SIG_OUTPUT_COMPARE1A) {

kontrolliere in der *.LSS Datei, ob das auch wirklich alles rechtens ist

ricola
03.01.2008, 14:36
hallo,

also mit der lss-datei kann ich leider nichts anfangen, hab sie
mal gepostet. dort steht was von bad_interrupts...

muss die sei() funktion nun eigentlich rein? wie gesagt, führt sie
bei mir zum ständig-reset.

weitere interrupts gibt es nicht!

ricola


main.elf: file format elf32-avr


Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000001a6 00000000 00000000 00000074 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .bss 00000023 00800100 00800100 0000021a 2**0
ALLOC
2 .stab 00000378 00000000 00000000 0000021c 2**2
CONTENTS, READONLY, DEBUGGING
3 .stabstr 00000071 00000000 00000000 00000594 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_aranges 00000020 00000000 00000000 00000605 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_pubnames 00000124 00000000 00000000 00000625 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_info 000002d5 00000000 00000000 00000749 2**0
CONTENTS, READONLY, DEBUGGING
7 .debug_abbrev 00000131 00000000 00000000 00000a1e 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_line 00000333 00000000 00000000 00000b4f 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_frame 00000030 00000000 00000000 00000e84 2**2
CONTENTS, READONLY, DEBUGGING
10 .debug_str 000001ab 00000000 00000000 00000eb4 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_loc 000000bc 00000000 00000000 0000105f 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:

00000000 <__vectors>:
0: 0c 94 2e 00 jmp 0x5c ; 0x5c <__ctors_end>
4: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
8: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
c: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
10: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
14: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
18: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
1c: 0c 94 4d 00 jmp 0x9a ; 0x9a <__vector_7>
20: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
24: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
28: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
2c: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
30: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
34: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
38: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
3c: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
40: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
44: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
48: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
4c: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
50: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
54: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>
58: 0c 94 4b 00 jmp 0x96 ; 0x96 <__bad_interrupt>

0000005c <__ctors_end>:
5c: 11 24 eor r1, r1
5e: 1f be out 0x3f, r1 ; 63
60: cf ef ldi r28, 0xFF ; 255
62: d4 e0 ldi r29, 0x04 ; 4
64: de bf out 0x3e, r29 ; 62
66: cd bf out 0x3d, r28 ; 61

00000068 <__do_copy_data>:
68: 11 e0 ldi r17, 0x01 ; 1
6a: a0 e0 ldi r26, 0x00 ; 0
6c: b1 e0 ldi r27, 0x01 ; 1
6e: e6 ea ldi r30, 0xA6 ; 166
70: f1 e0 ldi r31, 0x01 ; 1
72: 02 c0 rjmp .+4 ; 0x78 <.do_copy_data_start>

00000074 <.do_copy_data_loop>:
74: 05 90 lpm r0, Z+
76: 0d 92 st X+, r0

00000078 <.do_copy_data_start>:
78: a0 30 cpi r26, 0x00 ; 0
7a: b1 07 cpc r27, r17
7c: d9 f7 brne .-10 ; 0x74 <.do_copy_data_loop>

0000007e <__do_clear_bss>:
7e: 11 e0 ldi r17, 0x01 ; 1
80: a0 e0 ldi r26, 0x00 ; 0
82: b1 e0 ldi r27, 0x01 ; 1
84: 01 c0 rjmp .+2 ; 0x88 <.do_clear_bss_start>

00000086 <.do_clear_bss_loop>:
86: 1d 92 st X+, r1

00000088 <.do_clear_bss_start>:
88: a3 32 cpi r26, 0x23 ; 35
8a: b1 07 cpc r27, r17
8c: e1 f7 brne .-8 ; 0x86 <.do_clear_bss_loop>
8e: 0e 94 57 00 call 0xae ; 0xae <main>
92: 0c 94 d2 00 jmp 0x1a4 ; 0x1a4 <_exit>

00000096 <__bad_interrupt>:
96: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>

0000009a <__vector_7>:
* Every 100ms the timer function is
* called.
*
*/
SIGNAL (SIG_OUTPUT_COMPARE1A) {
9a: 1f 92 push r1
9c: 0f 92 push r0
9e: 0f b6 in r0, 0x3f ; 63
a0: 0f 92 push r0
a2: 11 24 eor r1, r1
a4: 0f 90 pop r0
a6: 0f be out 0x3f, r0 ; 63
a8: 0f 90 pop r0
aa: 1f 90 pop r1
ac: 18 95 reti

000000ae <main>:


//func();

PicNick
03.01.2008, 14:52
Sei(): ohne sei gibt's überhaupt keine Interrupts, damit umgehst du natürlich dein Problem, logo

EDIT Schwachsinn gestrichen, sonst liest das noch wer


Jetzt werd' ich mal die mega169 - h file suchen und schauen, wie das "SIGNAl ()" genau heissen muss


PS-EDIT: "bad interrupt" = nicht belegt => reset, wenn ausgelöst

ricola
03.01.2008, 15:14
meinst du das hier aus der iom169.h?

/* Timer/Counter1 Compare Match A */
#define TIMER1_COMPA_vect _VECTOR(7)
#define SIG_OUTPUT_COMPARE1A _VECTOR(7)

ricola
03.01.2008, 15:21
komisch, wenn ich jetzt

static void initInterrupt(void) {

TIMSK0 |= (1<<OCIE0A);
sei();
}

benutze mit

SIGNAL (SIG_OUTPUT_COMPARE0)

dann geht es, aber halt mit 8bit....

warum nur?

RICOLA

PicNick
03.01.2008, 15:24
Ja.
Ich merke, ich rede Schwachsinn (alterserscheinung) :oops:

Eigentlich bzw. letztlich seh ich keinen Fehler im Programm

Jetzt muß ich mir das Datasheet vom 169 suchen.

askazo
03.01.2008, 15:36
Mir fällt da sonst auch kein Fehler auf.
Poste doch bitte mal Deinen gesamten Code, da ist bestimmt irgendwo noch was faul.

askazo

ricola
03.01.2008, 17:23
ich wollte jetzt noch meine UART schnittstelle in betrieb nehmen, aber da
gibt es auch ein problem (siehe anderer thread). vielleicht gibt es einen
zusammenhang?

so wie es jetzt unten steht funktioniert der 8bit compare interrupt,
aber der 16er geht nicht mit

SIGNAL (SIG_OUTPUT_COMPARE1A)

und

TIMSK1 |= (1<<OCIE1A);
sei();

(Dauerreset des Controllers)






#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <inttypes.h>


// global vars
uint16_t ui_globalCounter = 0;
uint16_t ui_interruptCounter0 = 0;
uint16_t ui_interruptCounter1 = 0;
uint8_t uc_timerCounter = 0;
uint8_t uc_LEDgreen = 0;
uint8_t uc_LEDred = 0;

#define MYF_CPU 8000000UL
#define BAUDRATE 19200UL
#define MYUBRR MYF_CPU/16/BAUDRATE-1

uint16_t ubrr = MYUBRR;

int8_t c_incomingChar = 0;
uint8_t uc_incomingCharNew = 0;
uint8_t uc_incomingCharPos = 0;

SIGNAL (SIG_OUTPUT_COMPARE0) {

// counter then
//func(); //send_char!

}





static void initInterrupt(void) {

TIMSK0 |= (1<<OCIE0A);
sei();
}


static void initIO(void) {

// set port b,c,d and e as output
DDRB = 0xFF;
DDRC = 0xFF;
DDRD = 0xff;
DDRE = 0xff;

// clear all ports
PORTB &= ~(1<<0);
PORTB &= ~(1<<1);
PORTB &= ~(1<<2);
PORTB &= ~(1<<3);
PORTB &= ~(1<<4);
PORTB &= ~(1<<5);
PORTB &= ~(1<<6);
PORTB &= ~(1<<7);

PORTC &= ~(1<<0);
PORTC &= ~(1<<1);
PORTC &= ~(1<<2);
PORTC &= ~(1<<3);
PORTC &= ~(1<<4);
PORTC &= ~(1<<5);
PORTC &= ~(1<<6);
PORTC &= ~(1<<7);

PORTD &= ~(1<<0);
PORTD &= ~(1<<1);
PORTD &= ~(1<<2);
PORTD &= ~(1<<3);
PORTD &= ~(1<<4);
PORTD &= ~(1<<5);
PORTD &= ~(1<<6);
PORTD &= ~(1<<7);

PORTE &= ~(1<<0);
PORTE &= ~(1<<1);
PORTE &= ~(1<<2);
PORTE &= ~(1<<3);
PORTE &= ~(1<<4);
PORTE &= ~(1<<5);
PORTE &= ~(1<<6);
PORTE &= ~(1<<7);
}





static void initPWM(void) {

// init pwm timer

// 8bit timer/counter 0
TCCR0A = (1<<WGM00)|(1<<COM0A1)|(1<<CS01);
// set initial pwm
OCR0A = 200;


// 16bit timer/counter 1
TCCR1A = (1<<WGM10)|(1<<COM1A1)|(1<<COM1B1);
TCCR1B = (1<<CS10);
// set initial pwm
OCR1A = 200;
OCR1B = 200;


// 8bit timer/counter 2
TCCR2A = (1<<WGM20)|(1<<COM2A1)|(1<<CS21);
// set initial pwm
OCR2A = 200;



}



static void initUSART(void)
{

UBRRH = (uint8_t) (ubrr>>8);
UBRRL = (uint8_t) (ubrr);

// UART start receiver and transmitter
// data mode 8N1, asynchronous
UCSRB = (1 << RXEN) | (1 << TXEN);
UCSRC = (1 << UCSZ1) | (1 << UCSZ0);

// flush receive-buffer
do
{
UDR;
}
while (UCSRA & (1 << RXC));
}

static inline int sendChar (const uint8_t c)
{
// wait for uart -> ready
while (!(UCSRA & (1 << UDRE)))
;

// write/send char
UDR = c;

return 1;
}




int main(void) {

initIO();
initPWM();
initUSART();
initInterrupt();


while (1) {

// Motorports testweise setzen
PORTC |= (1<<0);
PORTC &= ~(1<<1);
PORTC |= (1<<2);
PORTC &= ~(1<<3);
PORTC |= (1<<4);
PORTC &= ~(1<<5);
PORTC |= (1<<6);
PORTC &= ~(1<<7);




}


return 1;


}

//eof



Gruß
RICOLA

pctoaster
03.01.2008, 18:04
Da fehlen auch einige Initialisierunmgen: Wie sind WGM10 /11 12 und 13 gesetzt ?
Hast Du schon mal in das Datenblatt geschaut ?
Signal sollte nicht mehr verwendet werden. Neu ist ISR(TIMER1_COMPA_vect)

Gruß
pctoaster

sorry, gerade sehe ich Deine Inis weiter unten. Aber ohne Datenblatt wirst Du trotzdem nicht weit kommen.

ricola
03.01.2008, 18:20
hallo,

die initialisierung ist korrekt, habe ich im datenblatt nachgesehen, danke
aber für den zweiten tip.

mein fehler war, dass ich das fuse bit CKDIV8 noch drinhatte, damit war
der takt falsch und der timer entsprechend auch. warum er dann neu
startet -> keine ahnung. jedenfalls geht es jetzt prima. bin drauf gekommen,
da die ein problem mit der BAUDRATE gleichzeitig vorlag. dahte ich
hätte alle fuses richtig gesetzt, naja. ALSO DANKE AN ALLE!

gruß
ricola