Im writing some C/asm program for the AVR MCU. Im still learning as I go so I hope I have made some sort of mistake in my code.
I have a buffer volatile unsigned char suart_0_rx_buffer[SUART_0_BUF_SIZE+1];
in my C code that I am accessing in my asm code as below. All I want to do is store a byte s0_Rxbyte
in the buffer and increment the pointer s0_index
every time. 's0_Rxbyte` is always a non zero value.
suart_0_wr_buf_2: ldi s0_z_low, lo8(suart_0_rx_buffer)
ldi s0_temp1, hi8(suart_0_rx_buffer)
add s0_z_low, s0_index
adc s0_z_high,s0_temp1
suart_0_wr_buf_3: st Z+, s0_Rxbyte
inc s0_index
clr s0_temp1
st Z, s0_temp1
If I try and print the contents in a loop in my C code I am getting absolutely nothing.
I didnt want to attach everything here because it will be cluttered.
So does anyone see any problems with the asm code above ?
Managed to figure it out in the end. It was a case of a simple error in the assembly code that caused it write an incorrect location in the SRAM.
suart_0_wr_buf_2: clr s0_temp1
ldi s0_z_low, lo8(suart_0_rx_buffer)
ldi s0_z_high, hi8(suart_0_rx_buffer)
add s0_z_low, s0_index
adc s0_z_high, s0_temp1
suart_0_wr_buf_3: st Z+, s0_Rxbyte
inc s0_index
st Z, s0_temp1