PICcoder.co.uk Forum  


Post a new message in "Getting Started"
Name:
Subject:
This image contains a scrambled text, it is using a combination of colors, font size, background, angle in order to disallow computer to automate reading. You will have to reproduce it to post on my homepage Enter what you see: *
tips: hit Reload page before writing a text if you have difficulty reading characters in image
topic icon:
no
boardcode:
 Colour:  Size:   Close all tags
Message:

emoticons
B) ;) :) :P
:laugh: :ohmy: :sick: :angry:
:blink: :( :unsure: :kiss:
:woohoo: :lol: :silly: :pinch:
:side: :whistle: :evil: :S
:blush: :cheer: :huh: :dry:

Topic History of: Aseemble Language question
Max. showing the last posts - (Last post first)
Author Message
DaveS Sorry, pressed wrong button. I'll start again.



COUNT is an 8 bit file register and as such cannot be used as a PORTB bit.







Try:-



MOVLW 1 ;PUT 1 IN W



MOVWF COUNT ; PUT W IN COUNT



MAIN



movf COUNT,W;put contents of count in W



movwf PORTB ; W to PORTB



CALL DELAY1 ;WAIT 1 SECOND



clrf PORTB;TURN LED OFF



CALL DELAY1 ;WAIT 1 SEC



CALL DELAY1 ;WAIT 1 SECOND



INCF COUNT ;INCREMENT COUNT



GOTO MAIN ;LOOP FOREVER



This will cause the leds to count up in binary however. To achieve what you want replace incf COUNT with RLF COUNT, F
DaveS COUNT is an 8 bit file register and as such cannot be used as a PORTB bit.



Try:-





MOVLW 1 ;PUT 1 IN W



MOVWF COUNT ; PUT W IN COUNT



MAIN



movf;TURN ON LED



CALL DELAY1 ;WAIT 1 SECOND



BCF PORTB,COUNT ;TURN LED OFF



CALL DELAY1 ;WAIT 1 SEC



CALL DELAY1 ;WAIT 1 SECOND



INCF COUNT ;INCREMENT COUNT



GOTO MAIN ;LOOP FOREVER
Roger Hi,



I am new to PIC programming and have run into a problem with my code.



I want to set a spicific bit on PortB to light up a LED but I want to be able to change which bit I set so I thought I would set up a piece of code as below



MOVLW 1 ;PUT 1 IN W

MOVWF COUNT ; PUT W IN COUNT

MAIN

BSF PORTB,COUNT ;TURN ON LED

CALL DELAY1 ;WAIT 1 SECOND

BCF PORTB,COUNT ;TURN LED OFF

CALL DELAY1 ;WAIT 1 SEC

CALL DELAY1 ;WAIT 1 SECOND

INCF COUNT ;INCREMENT COUNT

GOTO MAIN ;LOOP FOREVER



Now what I expected to happen was for each led to come on and then go off starting with LED1 and moving up one at a time, but what actually happens is that LED0 comes on and then goes off.



The offending line is BSF PORTB,COUNT does anyone know why I cannot do this?