Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[General] Delay and subroutine

Status
Not open for further replies.

Baraah

Newbie
Joined
Jul 23, 2022
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
18
Hello i need to modyfiy this code

PORTB EQU 06; Port B Data Register
TRISBEQU86; Port B Direction Register
CNT EQU 20; GPR used as delay counter
CountOuter0equD'25'
CountInner0equD'20'

cblock0x20

CountOuter
CountInner
endc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Initialise Port B (Port A defaults to inputs).............

BANKSELTRISB; Select bank 1
MOVLW b'00000000' ; Port B Direction Code
MOVWFTRISB ; Load the DDR code into F86
BANKSELPORTB; Select bank 0
GOTOreset; Jump to main loop


; 'delay' subroutine ........................................


delay
movlwCountOuter0
movwfCountOuter
DecO
movlwCountInner0
movwfCountInner
DecI
nop
decfszCountInner, F
gotoDecI
decfszCountOuter, F
gotoDecO
return


; Start main loop ...........................................

reset CLRF PORTB ; Clear Port B Data

start
INCF PORTB ; Increment output at Port B
MOVLW 0FF ; Delay count literal
CALLdelay; Jump to subroutine 'delay'
GOTO start ; Repeat main loop always

END ; Terminate source code

Such that the output PORTB
Look this
00000001,00000010,00000100,00001000,00010000
 

Basically you want a variable that starts out as 0x01 and you left
shift it, with carry in if you want it to repeat after 8 shifts, before
each write to port.

Regards, Dana.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top