USART Interrupt beim ATXMega16D4

Gast #3447077
Lesenswert?

Hallo,

ich versuche gerade den USART "receive complete interrupt" Interrupt 
beim ATXMega16D4 mit fogendem Code ans laufen zu bekommen:
1
#include <avr/io.h>
2
#include <stdio.h>
3

4
#include <avr/interrupt.h>
5

6
void clock_init(void);
7
void usart_init(void);
8

9
unsigned char value;
10

11

12
int main(void)
13
{
14
  //init external crystal 13,824MHz
15
  clock_init();
16

17
  //PC2 as input
18
  PORTC.DIR &= ~(1<<PIN2);
19
  
20
  //init usart 
21
  usart_init();
22
  
23
  sei();
24
  
25
  
26
    while(1)
27
    {
28
      ;
29
    }
30
}
31

32
//init for external crystal with 13.824MHz
33
void clock_init(void)
34
{
35
  OSC_XOSCCTRL = OSC_XOSCSEL_XTAL_16KCLK_gc |
36
  OSC_FRQRANGE_12TO16_gc;
37
  OSC.CTRL |= OSC_XOSCEN_bm;
38
  while(!(OSC.STATUS & OSC_XOSCRDY_bm));
39
  CCP = CCP_IOREG_gc;
40
  CLK.CTRL = CLK_SCLKSEL_XOSC_gc;
41
}
42

43

44
void usart_init(void)
45
{
46
  //Baud Rate 115200 bits per second
47
  USARTC0.BAUDCTRLB = 0xF0;
48
  USARTC0.BAUDCTRLA = 13;
49
  
50
  //high priority for RX-interrupt
51
  USARTC0.CTRLA = USART_RXCINTLVL_HI_gc;
52
  //enable the receive complete interrupt and select the interrupt level
53
  USARTC0.CTRLA = USART_RXCINTLVL0_bm | USART_RXCINTLVL1_bm;
54
  //Receiver Enable
55
  USARTC0.CTRLB = USART_RXEN_bm;
56
  //Asynchronous USART / 8data_bit - 1stop_bit - 0parity
57
  USARTC0.CTRLC  = 0x03;
58
}
59

60

61
ISR(USARTC0_RXC_vect)
62
{
63
  value = USARTC0.DATA; 
64
}


Sende ich ein Byte vom PC über die USART Schnittstelle (Seriell to UART 
Converter), wird das Receive Interrupt Flag gesetzt aber die Interrupt 
Routine nicht ausgeführt. Hab ich noch irgendetwas vergessen?

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