Guest User

Untitled

a guest
Sep 19th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define F_CPU 7372800UL
  2. #define USART_BAUDRATE 9600
  3. #define UBRR_ERTEK ((F_CPU / (USART_BAUDRATE * 16UL)) - 1)
  4.  
  5. void KonfigUART()  // UART beallitasa
  6. {
  7.    // 9600 bps soros kommunikacio sebesseg beallitasa
  8.    UBRRL = UBRR_ERTEK;        // UBRR_ERTEK also 8 bitjenek betoltese az UBRRL regiszterbe
  9.    UBRRH = (UBRR_ERTEK>>8);   // UBRR_ERTEK felso 8 bitjenek betoltese az UBRRH regiszterbe
  10.    // Aszinkron mod, 8 Adat Bit, Nincs Paritas Bit, 1 Stop Bit
  11.    UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1);
  12.    //Ado es Vevo aramkorok bekapcsolasa
  13.    UCSRB |= (1 << RXEN) | (1 << TXEN);   //
  14. }
  15.  
  16. void rs232_send_byte(char data) {
  17.    while(!(UCSRA & (1<<UDRE)));
  18.    UDR=data;
  19. }
  20.  
  21. void rs232_send_line(const char *str) {
  22.  
  23.     while (*str) {
  24.         rs232_send_byte(*str++);
  25.     }
  26.  
  27. }
  28.  
  29. rs232_send_line("Ez egy teszt sor.");
  30.  
  31.  
  32.  
  33.  
  34.  
  35. ====================================
  36. Kimenet:
  37.  
  38. E\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xff\0xa15\0x01\0x01\0x03}`
Advertisement
Add Comment
Please, Sign In to add comment