Forum: Mikrocontroller und Digitale Elektronik uart mega16


von Arndt Staudinger (Gast)


Lesenswert?

Hallo,
Ich habe folgendes Problem:
Die Uart sendet nix, obwohl eigendlich alles sauber compiliert. Wo
steckt der Wurm?

Danke für hilfreiche Beiträge.

Tschau

#include <avr/io.h>

void UART_init(void)
 {

 // Baudrate einstellen

 sbi(UBRRH,7);            // Zugriff auf UBRRH ermöglichen
 UBRRH = (UBRRH | 0x00);
 UBRRL = 51;            // 9600 bps

  // Frame Format einstellen

 cbi(UCSRC,7);               // Zugriff auf UCSRC
 cbi(UCSRC,6);             // Asynchrone Übertragung
 UCSRC = (UCSRC | 0x10);   // Even Parity
 cbi(UCSRC,3);            // 1 Stop Bit
 UCSRC = (UCSRC | 0x03);   // 8 Datenbit
 cbi(UCSRB,2);

 // RxD, TxD freischalten

 sbi(UCSRB,3);            // TxD Pin freischalten
 cbi(UCSRB,4);           // RxD Pin freischalten

 }

void send_fkt(char byte)
 {
  while ( !(UCSRA & (1<<UDRE)));
  UDR = byte;
 }

int main(void)
 {

  outp (0x00, DDRA);       //PortA: alles als EINGANG      !!! SONST 
UNGLÜCK
!!!!
  outp (0xff, PORTA);        // Interne Pull-Up Widerstände ein !!! 
SONST
UNGLÜCK !!!!

  outp (0x00, DDRB);       //PortB: alles als EINGANG
  outp (0xff, PORTB);        // Interne Pull-Up Widerstände ein

  outp (0x00, DDRC);       //PortB: alles als EINGANG
  outp (0xff, PORTC);        // Interne Pull-Up Widerstände ein

  outp (0x00, DDRD);       //PortD: alles als EINGANG
  outp (0xff, PORTD);        // Interne Pull-Up Widerstände ein

  UART_init();


  while(1)
    {
    send_fkt('O');    // Zeichen übertragen
    send_fkt('k');
    send_fkt(' ');
    }
  return 0;
 }

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.