Gast
#5690
Hiho!
da das bei mir irgendwie nciht hinhaut mit dem senden eines Zeichens
über die serielle Schnittstelle, wollte ich mal fragen ob es nicht
vielleicht schon eine Lib in C gibt die ein Software UART bereitstellt.
Falls nicht vielleicht weiß ja jmd. warum bei mir folgender simpler Code
fehlschlägt: (Hyperterminal empfängt 'Ç' (ASCII 128), statt 'U' (ASCII
85).
//Include
#include <IO.H>
#include <IOM8.H>
//Funktionsprototypen
void delay417cycles(void);
int main(void)
{
outp(0x66,DDRD); // config Port D
while (1)
{
//Sende ein 'U'
sbi(PORTD, PIND5); //Start
delay833cycles();
cbi(PORTD, PIND5); //Bit1
delay833cycles();
sbi(PORTD, PIND5); //Bit2
delay833cycles();
cbi(PORTD, PIND5); //Bit3
delay833cycles();
sbi(PORTD, PIND5); //Bit4
delay833cycles();
cbi(PORTD, PIND5); //Bit5
delay833cycles();
sbi(PORTD, PIND5); //Bit6
delay833cycles();
cbi(PORTD, PIND5); //Bit7
delay833cycles();
sbi(PORTD, PIND5); //Bit8
delay833cycles();
cbi(PORTD, PIND5); //Stopp
delay833cycles();
}
}
void delay833cycles(void)
{
asm volatile
(
//-----------------------------
// delaying 828 cycles:
" ldi R17, 0x02" "\n\t"
"WGLOOP6: ldi R18, 0x89" "\n\t"
"WGLOOP7: dec R18 " "\n\t"
" brne WGLOOP7 " "\n\t"
" dec R17 " "\n\t"
" brne WGLOOP6 " "\n\t"
//-----------------------------
//delaying 3 cycles:
" ldi R17, 0x01" "\n\t"
"WGLOOP8: dec R17 " "\n\t"
" brne WGLOOP8 " "\n\t"
//-----------------------------
//delaying 2 cycles:
" nop " "\n\t"
" nop " "\n\t"
//=============================
:
:
);
}