kgavionics
Full Member level 3
- Joined
- Jun 12, 2012
- Messages
- 167
- Helped
- 7
- Reputation
- 14
- Reaction score
- 11
- Trophy points
- 1,298
- Location
- Alberta.Canada
- Activity points
- 2,482
hi
i made a little project based on pic 16f8777a to convert a analog pot movement (from zero to 5v) to binary value on 8 led attached to portd. Everything works pretty fine and i want to do a modification that when i rotate the pot the led lights up linearly like a progress bar.
i use assembler to write my program and i use proteus to simulate before implementing the project on breadboard. i have a little problem here because obviously my code doesn't work.Here's the routine that displays the led on portd:
Sort
movlw 0x1f
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display0
movlw 0x20
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display1
movlw 0x40
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
movf ADRESH,W
goto display2
movlw 0x60
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display3
movlw 0x80
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display4
movlw 0xa0
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display4
movlw 0xc0
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display4
movlw 0xe0
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display5
movlw 0xff
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display6
return
the idea of routine is to check if the converted binary number is belonging to wish intervals (we have 8 intervals, because we have 256/8).Depending on the interval , the corresponding leds are lighted.
for instance, between 0 and 31----led1 is on
between 32 and 64---led1 and led2 are on.
and so on.
can you help me please and want to know what's wrong with my code ????
thank you in advance and i'm sorry because i'm a newbie to micro controllers programming.
i made a little project based on pic 16f8777a to convert a analog pot movement (from zero to 5v) to binary value on 8 led attached to portd. Everything works pretty fine and i want to do a modification that when i rotate the pot the led lights up linearly like a progress bar.
i use assembler to write my program and i use proteus to simulate before implementing the project on breadboard. i have a little problem here because obviously my code doesn't work.Here's the routine that displays the led on portd:
Sort
movlw 0x1f
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display0
movlw 0x20
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display1
movlw 0x40
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
movf ADRESH,W
goto display2
movlw 0x60
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display3
movlw 0x80
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display4
movlw 0xa0
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display4
movlw 0xc0
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display4
movlw 0xe0
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display5
movlw 0xff
movwf reg
bsf STATUS,C
movf ADRESH,W
subwf reg,1
btfsc STATUS,C
goto display6
return
the idea of routine is to check if the converted binary number is belonging to wish intervals (we have 8 intervals, because we have 256/8).Depending on the interval , the corresponding leds are lighted.
for instance, between 0 and 31----led1 is on
between 32 and 64---led1 and led2 are on.
and so on.
can you help me please and want to know what's wrong with my code ????
thank you in advance and i'm sorry because i'm a newbie to micro controllers programming.