Moin!
Na das ist die ab dem '3:' 
Das ganze hat sich aber gerade sowieso erledigt:
einmal meine softuart.c
Code:
#include "softuart.h"
void txd (unsigned char value)
{
uint8_t bitcnt = 1+8+STOP_BITS;
uint8_t delay = bvalue; //see softuart.h
value = ~value;
cli();
__asm__ __volatile__(
" sec ; Start bit " CR_TAB
"0: brcc 1f ; If carry set " CR_TAB
" sbi %[port],%[pad] ; send a '0' " CR_TAB
" rjmp 2f ; else " CR_TAB
"1: cbi %[port],%[pad] ; send a '1' " CR_TAB
" nop" CR_TAB
"2: %~call bit_delay_%= ; One bit delay " CR_TAB
" %~call bit_delay_%=" CR_TAB
" lsr %[value] ; Get next bit " CR_TAB
" dec %[bitcnt] ; If not all bit sent " CR_TAB
" brne 0b ; send next " CR_TAB
" rjmp 5f ; else: done " CR_TAB
CR_TAB
"bit_delay_%=:" CR_TAB
" mov __zero_reg__, %[delay]" CR_TAB
"4: dec __zero_reg__" CR_TAB
" brne 4b" CR_TAB
" ret" CR_TAB
"5:" CR_TAB
: [bitcnt] "=r" (bitcnt), [value] "=r" (value)
: "1" (value), "0" (bitcnt), [delay] "r" (delay), [port] "M" (_SFR_IO_ADDR(SWUART_PORT)), [pad] "M" (SWUART_PIN)
);
sei();
}
und dazu meine softuart.h
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#define CR_TAB "\n\t"
#define STOP_BITS 1
#define bvalue 19 //115200 Baud
#define SWUART_PORT PORTC //TX Port
#define SWUART_PIN 5 //TX Pin
/*
b-values for 16 MHz
BaudRate Cycles required b-value Error %
2400 6667 (2) 1107 0
4800 3333 (2) 552 0
9600 1667 (2) 274 0
14400 1111 181 0,2
19200 833 135 0
28800 556 89 0,3
57600 278 42 1
115200 139 19 1,4
*/
void txd (unsigned char value) ;
Bei anderen Frequenzen in der AppNote AVR305 nachschauen...
Dieser Software-UART braucht nichts außer einem freien Pin, praktisch zum debuggen z.B..
Falls das noch jemand braucht, einfach in der softuart.h Port und Pin sowie Verzögerung für die Baudrate lt. Liste anpassen und los gehts.
Trotzdem danke!!
Lesezeichen