Moin moin.
Folgendes Problem: Ich hab ein Rechtecksignal an INT0, und ich will ca.
wissen, wieviel mal pro sekunde das zwischen 0 und 5v hin und her
schwankt ( muss nicht allzugenau sein ) und das per UART auf den PC
übertragen. Hier ein Ausschnit aus meinem Code:
1 | typedef union {
|
2 | uint16_t l;
|
3 | uint8_t b[2];
|
4 | } typ_mixed;
|
5 |
|
6 | typ_mixed gs;
|
7 |
|
8 |
|
9 | SIGNAL(SIG_INTERRUPT0){
|
10 | gs.l++;
|
11 | }
|
12 |
|
13 | main(void){
|
14 | MCUCR |= (1<<ISC10)|(1<<ISC00);
|
15 | uart_init();
|
16 | for(;;){
|
17 | gs.l=0
|
18 | GICR |= (1<<INT0)|(1<<INT1);
|
19 | wait(500);
|
20 | GICR &= ~(1<<INT0)|(1<<INT1);
|
21 | uart_send(gs.b[0]);
|
22 | uart_send(gs.b[1]);
|
23 | }
|
24 | }
|
Hier mein Problem: Selbst wenn ich INT0 dauernd auf Masse habe, sendet
mir der AVR nur Kram zurueck: Zb 0x01 0xad anstatt 0x00 0x00.
Wie kann das sein? Alle anderen Kommunikationen per uart funktionieren
einwandfrei!