;
; Serial USART.asm
;
; Created: 4/15/2018 9:24:49 PM
;
.equ UBRRNX0=103 ; 9600bps
.equ UBRRNX1=207
// start code
start:
rcall USART_Init
; write your code here
ldi r16,0x24
rcall USART_Transmit
end:
rjmp end
; end of your code
; this is my part
;----------
USART_Init:
push r16
push r17
ldi r16, low(UBRRNX0) ; Set baud rate to UBRR0
ldi r17, high(UBRRNX0)
sts UBRR0H, r17
sts UBRR0L, r16
sts UCSR0B,r16
sts UCSR0C,r16
pop r17
pop r16
ret
USART_Transmit:
push r17
lds r17, UCSR0A ; Wait for empty transmit buffer
sbrs r17, UDRE0
rjmp USART_Transmit
sts UDR0,r16 ; Put data (r16) into buffer, sends the data
pop r17
ret
I am really glad I’ve found this info. Today bloggers publish just about gossip and internet stuff and this is really frustrating. A good website with interesting content, that’s what I need. Thanks for making this site, and I will be visiting again. Do you do newsletters by email? and please visit my website. prediksi mix parlay
ReplyDeleteThanks a lot, very helpful, but there is a small a mistake in the code USART_Transmit: push r17
ReplyDeleteYou loop USART_Transmit so on every loop you push r17 on the stack, so you need to put a different loop label after the push r17, thanks.