diff options
author | FreeArtMan <dos21h@gmail.com> | 2021-05-27 20:06:47 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2021-05-27 20:06:47 +0100 |
commit | e63ed8a651e5246f8698a9c1c3e540029710d0e9 (patch) | |
tree | cfd58d80345f17dc9f458bad88181811a89b3592 /md/writeup/avr_echo.md | |
parent | 9b9586b559edb387af804c52d2b593b711ce98be (diff) | |
download | md-content-e63ed8a651e5246f8698a9c1c3e540029710d0e9.tar.gz md-content-e63ed8a651e5246f8698a9c1c3e540029710d0e9.zip |
Update 10 articles from html to md
Diffstat (limited to 'md/writeup/avr_echo.md')
-rw-r--r-- | md/writeup/avr_echo.md | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/md/writeup/avr_echo.md b/md/writeup/avr_echo.md new file mode 100644 index 0000000..0dac9fb --- /dev/null +++ b/md/writeup/avr_echo.md @@ -0,0 +1,36 @@ +title:AVR echo +keywords:avr,echo,c,atmega + + +# AVR echo +This code tested on ATmega16 + +```c +#include <avr/io.h> + +#define FOSC 16000000UL +#define BAUD 9600 +#define MYUBRR FOSC/16/BAUD-1 + +void USART_Init( unsigned int ubrr) +{ + UBRRH = (unsigned char)(ubrr>>8); + UBRRL = (unsigned char)ubrr; + UCSRB = (1<<RXEN)|(1<<TXEN); + UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0); +} + +int main() +{ + char c; + USART_Init( MYUBRR ); + while(1) + { + while ( !(UCSRA & (1<<RXC))){}; + c = UDR; + while (!(UCSRA & (1<<UDRE))){}; + UDR = c; + } + return 0; +} +``` |