Rev 1528 | Rev 1598 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1528 | Rev 1561 | ||
---|---|---|---|
Line 89... | Line 89... | ||
89 | 89 | ||
90 | 90 | ||
91 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
91 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
92 | //++ Sende-Part der Datenübertragung |
92 | //++ Sende-Part der Datenübertragung |
93 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
93 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
94 | SIGNAL(INT_VEC_TX) |
94 | ISR(USART0_TX_vect) |
95 | { |
95 | { |
96 | static unsigned int ptr = 0; |
96 | static unsigned int ptr = 0; |
97 | unsigned char tmp_tx; |
97 | unsigned char tmp_tx; |
Line 102... | Line 102... | ||
102 | if((tmp_tx == '\r') || (ptr == MAX_SENDE_BUFF)) |
102 | if((tmp_tx == '\r') || (ptr == MAX_SENDE_BUFF)) |
103 | { |
103 | { |
104 | ptr = 0; |
104 | ptr = 0; |
105 | UebertragungAbgeschlossen = 1; |
105 | UebertragungAbgeschlossen = 1; |
106 | } |
106 | } |
107 | UDR = tmp_tx; |
107 | UDR0 = tmp_tx; |
108 | } |
108 | } |
109 | else ptr = 0; |
109 | else ptr = 0; |
110 | } |
110 | } |
Line 111... | Line 111... | ||
111 | 111 | ||
112 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
112 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
113 | //++ Empfangs-Part der Datenübertragung, incl. CRC-Auswertung |
113 | //++ Empfangs-Part der Datenübertragung, incl. CRC-Auswertung |
114 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
114 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
115 | SIGNAL(INT_VEC_RX) |
115 | ISR(USART0_RX_vect) |
116 | { |
116 | { |
117 | static unsigned int crc; |
117 | static unsigned int crc; |
118 | static unsigned char crc1,crc2,buf_ptr; |
118 | static unsigned char crc1,crc2,buf_ptr; |
119 | static unsigned char UartState = 0; |
119 | static unsigned char UartState = 0; |
Line 120... | Line 120... | ||
120 | unsigned char CrcOkay = 0; |
120 | unsigned char CrcOkay = 0; |
121 | 121 | ||
122 | SioTmp = UDR; |
122 | SioTmp = UDR0; |
123 | if(buf_ptr >= MAX_SENDE_BUFF) UartState = 0; |
123 | if(buf_ptr >= MAX_SENDE_BUFF) UartState = 0; |
124 | if(SioTmp == '\r' && UartState == 2) |
124 | if(SioTmp == '\r' && UartState == 2) |
125 | { |
125 | { |
Line 183... | Line 183... | ||
183 | tmpCRC %= 4096; |
183 | tmpCRC %= 4096; |
184 | TxdBuffer[i++] = '=' + tmpCRC / 64; |
184 | TxdBuffer[i++] = '=' + tmpCRC / 64; |
185 | TxdBuffer[i++] = '=' + tmpCRC % 64; |
185 | TxdBuffer[i++] = '=' + tmpCRC % 64; |
186 | TxdBuffer[i++] = '\r'; |
186 | TxdBuffer[i++] = '\r'; |
187 | UebertragungAbgeschlossen = 0; |
187 | UebertragungAbgeschlossen = 0; |
188 | UDR = TxdBuffer[0]; |
188 | UDR0 = TxdBuffer[0]; |
189 | } |
189 | } |
Line 190... | Line 190... | ||
190 | 190 | ||
Line 475... | Line 475... | ||
475 | //############################################################################ |
475 | //############################################################################ |
476 | //Routine für die Serielle Ausgabe |
476 | //Routine für die Serielle Ausgabe |
477 | void uart_putchar (char c) |
477 | void uart_putchar (char c) |
478 | //############################################################################ |
478 | //############################################################################ |
479 | { |
479 | { |
480 | //if (c == '\n') uart_putchar('\r'); |
- | |
481 | //Warten solange bis Zeichen gesendet wurde |
480 | //Warten solange bis Zeichen gesendet wurde |
482 | loop_until_bit_is_set(USR, UDRE); |
481 | loop_until_bit_is_set(UCSR0A, UDRE0); |
483 | //Ausgabe des Zeichens |
482 | //Ausgabe des Zeichens |
484 | UDR = c; |
483 | UDR0 = c; |
485 | } |
484 | } |
Line 486... | Line 485... | ||
486 | 485 | ||
487 | 486 | ||
488 | //############################################################################ |
487 | //############################################################################ |
489 | //INstallation der Seriellen Schnittstelle |
488 | //INstallation der Seriellen Schnittstelle |
490 | void UART_Init (void) |
489 | void UART_Init (void) |
491 | //############################################################################ |
490 | //############################################################################ |
Line -... | Line 491... | ||
- | 491 | { |
|
492 | { |
492 | unsigned int ubrr = (unsigned int) ((unsigned long) F_CPU/(8 * USART0_BAUD) - 1); |
493 | //Enable TXEN im Register UCR TX-Data Enable & RX Enable |
493 | |
494 | 494 | //Enable TXEN im Register UCR TX-Data Enable & RX Enable |
|
495 | UCR=(1 << TXEN) | (1 << RXEN); |
495 | UCSR0B = (1 << TXEN0) | (1 << RXEN0); |
496 | // UART Double Speed (U2X) |
496 | // UART Double Speed (U2X) |
497 | USR |= (1<<U2X); |
497 | UCSR0A |= (1 << U2X0); |
498 | // RX-Interrupt Freigabe |
498 | // RX-Interrupt Freigabe |
- | 499 | UCSR0B |= (1 << RXCIE0); |
|
- | 500 | // TX-Interrupt Freigabe |
|
- | 501 | UCSR0B |= (1 << TXCIE0); |
|
- | 502 | // USART0 Baud Rate Register |
|
Line 499... | Line -... | ||
499 | UCSRB |= (1<<RXCIE); |
- | |
500 | // TX-Interrupt Freigabe |
- | |
501 | UCSRB |= (1<<TXCIE); |
- | |
502 | - | ||
503 | //Teiler wird gesetzt |
- | |
504 | UBRR=(SYSCLK / (BAUD_RATE * 8L) - 1); |
- | |
505 | //UBRR = 33; |
503 | // set clock divider |
506 | //öffnet einen Kanal für printf (STDOUT) |
504 | UBRR0H = (uint8_t)(ubrr >> 8); |
Line 507... | Line 505... | ||
507 | //fdevopen (uart_putchar, 0); |
505 | UBRR0L = (uint8_t)ubrr; |
508 | //sbi(PORTD,4); |
506 |