sei(); legt ATMega lahm

Gast #4494115
Lesenswert?
• ▲
▼
Hallo Leute,

ich sitze aktuell daran, ein Grafik LCD anzusteuern. Verwendet wird ein 
AtMega32, bei 10Mhz.
Das funktioniert soweit wunderbar, allerdings legt es mir den AVR lahm, 
sobald ich ich die Funktion "sei();" aufrufe. Dazu folgender Quellcode:
1
int main(void)
2
{
3
DDRD |= (1<<PD0);
4
PORTD |= (1<<PD0); 
5
GLCD_Init();
6
Taster_Init();
7
//sei();
8
  
9
PORTD &= ~(1<<PD0);
10
}
An PD0 hängt eine LED zum debuggen. Wenn ich das Kommentar vor sei(); 
entferne, erlischt die LED nicht mehr, sodass ich davon ausgehe, dass er 
sich irgendwo aufhängt.
Klammere ich die Funktion GLCD_init aus, erlischt die LED und der AVR 
scheint sich nicht aufzuhängen.
Gibt es hierbei ein Problem mit den Timern?

Funktion GLCD_Init
1
void GLCD_Init(void)
2
{
3
  DDR_Helligkeit |= (1<<PIN_Helligkeit);
4
  DDR_Kontrast |= (1<<PIN_Kontrast);
5
  
6
  DDR_DB = OUTPUT;
7
  
8
  DDR_E |= (1<<PIN_E);
9
  DDR_RST |= (1<<PIN_RST);
10
  DDR_RW |= (1<<PIN_RW);
11
  DDR_DI |= (1<<PIN_DI);
12
  DDR_CS1 |= (1<<PIN_CS1);
13
  DDR_CS2 |= (1<<PIN_CS2);
14
  
15
  //Werte aus EEPROM laden
16
  TIMER_Kontrast = eeprom_read_byte(&Kontrast);  
17
  TIMER_Helligkeit = eeprom_read_byte(&Helligkeit);
18
  
19
  //Timer starten
20
  Timer_Helligkeit_Start();
21
  Timer_Kontrast_Start();
22
  
23
  //Init Display  
24
  GLCD_reset();
25
  
26
  _delay_ms(50);
27
  
28
  //Linke Seite
29
  GLCD_put(0x3F, GLCD_Instruction, GLCD_Links);  //LCD an
30
    GLCD_put(0xC0, GLCD_Instruction, GLCD_Links);  //Startline = 0  
31
    GLCD_put(0xB8, GLCD_Instruction, GLCD_Links);  //Set X-Adress
32
   GLCD_put(0x40, GLCD_Instruction, GLCD_Links);  //Set Y-Adress
33
  //Rechte Seite
34
  GLCD_put(0x3F, GLCD_Instruction, GLCD_Rechts);  //LCD an
35
  GLCD_put(0xC0, GLCD_Instruction, GLCD_Rechts);  //Startline = 0
36
  GLCD_put(0xB8, GLCD_Instruction, GLCD_Rechts);  //Set X-Adress
37
  GLCD_put(0x40, GLCD_Instruction, GLCD_Rechts);  //Set Y-Adress
38
  
39
  _delay_ms(50);
40
  
41
  GLCD_clear();
42
}
Timer-Funktionen
1
void Timer_Kontrast_Start(void)
2
{
3
  // Timer 1 / Kontrast
4
  // Vorteiler = 1; FastPWM 8Bit; 39Khz PWM
5
  TCCR1A |= (1<<WGM10)|(1<<COM1A1);
6
  TCCR1B |= (1<<CS10)|(1<<WGM12);
7
}
8

9
void Timer_Helligkeit_Start(void)
10
{
11
  //Timer 2 / Helligkeit
12
  //Vorteiler = 1
13
  TCCR2 |= (1<<CS20)|(1<<WGM21)|(1<<WGM20)|(1<<COM20)|(1<<COM21);
14
}
Funktion Taster_init
1
void Taster_Init(void)
2
{
3
  
4
  //DDRD &= ~((1<<PD2)|(1<<PD1)|(1<<PD3));
5
  DDRB &= ~((1<<PB0)|(1<<PB1)|(1<<PB2)|(1<<PB3));
6
  
7
  //PORTD |= (1<<PD2)|(1<<PD1)|(1<<PD3);
8
  PORTB |= (1<<PB0)|(1<<PB1)|(1<<PB2)|(1<<PB3);
9
  
10
  //Externen Interrupt aktivieren
11
   MCUCR |= (1<<ISC11)|(1<<ISC01);    //fallende Flanke
12
   GICR |= (1<<INT1)|(1<<INT0);      //Interrupt aktivieren
13

14
}

Vielen Dank für eure Hilfe!

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