can you tell me what is wrong with the following code. In that code when analog comparator output is high the counter should work but it is not working. I checked output of the T flag and analog comparator they are high then also counter is not working. Can you correct the code
I am also facing probs when I am using 'rcall'
Till now I am able to use only 'rjmp'
I am using avrstudio4.0, avrdude programmer, atmega8515
The other problem i am facing is of delay
avrstudio shows delay 139ms for 4MHz and if i use the following
delay function for 8MHz I am getting of delay b/w .5 to 1sec
.cseg
.org 0
rjmp RESET
RESET:
ldi r16,0xff
out $14,r16 ;PORTC as output
out $1a,r16
out $11,r16
ldi r16,0x08
out $08,r16
ldi r18,00
ldi r17,01
LOOP:
in r16,$08
out $1b,r16
bst r16,5 ;moving Bit5 of the analog comp.
;register to T flag(Bit copy storage)
in r11,$3f
out $12,r11
brts counter
rjmp LOOP
counter:
add r18,r17
out $15,r18
rjmp delay
delay:
; -----------------------------
; delaying 555552 cycles:
ldi R19, $04
WGLOOP0: ldi R18, $C5
WGLOOP1: ldi R20, $EA
WGLOOP2: dec R20
brne WGLOOP2
dec R18
brne WGLOOP1
dec R19
brne WGLOOP0
; -----------------------------
; delaying 3 cycles:
ldi R19, $01
WGLOOP3: dec R19
brne WGLOOP3
; =============================
rjmp LOOP