Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 7372800UL
- #define USART_BAUDRATE 9600
- #define UBRR_ERTEK ((F_CPU / (USART_BAUDRATE * 16UL)) - 1)
- void KonfigUART() // UART beallitasa
- {
- // 9600 bps soros kommunikacio sebesseg beallitasa
- UBRRL = UBRR_ERTEK; // UBRR_ERTEK also 8 bitjenek betoltese az UBRRL regiszterbe
- UBRRH = (UBRR_ERTEK>>8); // UBRR_ERTEK felso 8 bitjenek betoltese az UBRRH regiszterbe
- // Aszinkron mod, 8 Adat Bit, Nincs Paritas Bit, 1 Stop Bit
- UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1);
- //Ado es Vevo aramkorok bekapcsolasa
- UCSRB |= (1 << RXEN) | (1 << TXEN); //
- }
- void rs232_send_byte(char data) {
- while(!(UCSRA & (1<<UDRE)));
- UDR=data;
- }
- void rs232_send_line(const char *str) {
- while (*str) {
- rs232_send_byte(*str++);
- }
- }
- rs232_send_line("Ez egy teszt sor.");
- ====================================
- Kimenet:
- 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