I try to use the branch instruction
cp r16,r7
brlo rtem3
- that is not working.. if instead of this i use a constant number
- cpi r16,0x08
- brlo rtem3
- then it works! ( r16 contains a variable)
- what i have done wrong ?
- thank you in advance
I try to use the branch instruction
cp r16,r7
brlo rtem3
how do you put 0x08 into r7 ?
remember that ldi don't work on r0-r15
yes i did
ldi r16,0x08
mov r7,r16
Can you show the full code not just dribs and drabs. Presumably after you use R16 to get the 0x08 into R7 you then did something else to get another value into R16? Otherwise they both have 0x08 at the point of the CP.
of course r16 have the number of an ADC conversion ..
of course
when i use the same code but with the instruction << cpi >> everything are good when i use with <<cp >> no ...r16 has in both situations the same code that gave it the number What is more i stop the program and i <<ask>> AVR to out portb what it has in r16 -r7 and they have what it is supposed to have!
AVR opcodes are deterministic. The only thing that can possibly be different here is the input data. That's why it's so important for you to show how you are deriving your input data.
when i use the same code but with the instruction << cpi >> everything are good when i use with <<cp >> no ...r16 has in both situations the same code that gave it the number What is more i stop the program and i <<ask>> AVR to out portb what it has in r16 -r7 and they have what it is supposed to have!
What you are saying is that the cp instruction doesn't work. This is basically not possible, unless you are running the CPU out of spec, like overclocking, undervoltage, noisy clock or whatever.
So r7 doesn't have the value you think it has. Maybe it was changed by an interrupt?
Give us the smallest possible complete program that reproduces the problem and we will try to test it.
as soon as i will be with my computer i send you the code.. thank you anyway