1 year ago
#336220
Jarne_789
Read data from X pointer and save it in an array - AVR Asm
I'm learning Avr Assembly. I'm writing a project that reads a uart string, then the string has to be saved in an array. Then the string has to be send back on the uart TX pin. I'm programming a ATMEGA8 microcontroller. I'm not sure everything is correct and probably some code will not be correct since I'm a starter in ASM avr.
first, I call the 'gets' subroutine to get the data from the uart pins. (I have the code from http://www.rjhcoding.com/avr-asm-uart.php)
gets:
in r17, UCSRA
sbrs r17, RXC
rjmp gets
in r16, UDR ; gets received character
cpi r16, $0D ; check if rcv'd char is CR (enter)
breq gets_end ; branch if CR
st X+,r16 ; store char in buffer
rjmp gets ; get another char
gets_end:
ldi r16, $00
st X+,r16
ret
But what I don't get about this code, how do I read the data in the X buffer and put it in a new Array? And how do I make and use that array?
assembly
avr
uart
atmega
atmel
0 Answers
Your Answer