riccardo
Member
Hi,
I'm trying to generate a pulse train on PORTB of a 18F2455. I had a simple Idea of running a loop and incrementing the port number, but this gives me an 'argument out of range message. Does anyone know how to do this properly?
I've just listed "channel" in a cblock and set it to 0 before this loop
I'm trying to generate a pulse train on PORTB of a 18F2455. I had a simple Idea of running a loop and incrementing the port number, but this gives me an 'argument out of range message. Does anyone know how to do this properly?
I've just listed "channel" in a cblock and set it to 0 before this loop
Code:
Step
BSF PORTB, channel ; Set output channel high
CALL Wait ; Delay
BCF PORTB, channel ; Clear output channel
CALL Wait ; Delay
INCF channel
; If channel > 7 make it 0
MOVF channel, W ; Copy channel value to W for testing
SUBWF 8, W ; Subtract W from 8
BTFSC STATUS, Z ; Check if result is Zero (channel needs to be reset)
CLRF channel ; Reset to zero
GOTO Step