I'm writing this code in assembly for AVR ATmega16 microcontroller using AtmelStudio 7. I'm trying to read some data from program memory and using them. I know that i have to use Z register to point the program memory and the pre-stored data is recognized by the label "BCDTo7_Seg" by the assembler. It does read the first number in that table(I can see this procedure using the debugger) but, when i post increment the Z register the address increases but the read value is still the same! Hope someone could help me out. Here is a part of the code:
/* Simply start reading from program memory */
/* The reading from program memory must be done with the starting address: BCDTo7_Seg LABEL */
/* INITIALIZE Z POINTER */
ldi ZH,high(BCDTo7_Seg << 1)
ldi ZL,low(BCDTo7_Seg << 1)
clr R23
/* R23 contains the data must be written to the 7 segment */
/* Post Increment Z after reading each number */
lpm R23,Z+
/* decrement R16 */
dec R16
/* Check the loop end point */
brne R_W
rjmp start
Every time it executes it sets pointer at the beginning.
ldi ZH,high(BCDTo7_Seg << 1)
ldi ZL,low(BCDTo7_Seg << 1)