Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4787

Port Digital Output Not Changing Properly

$
0
0
Hi,

I'm using a 18F4550 PIC code that's running on PBP2.50. I'm pulling my hair out trying to figure out why this code won't work. :confused:

Code:

DUMMYVAR VAR BYTE

TRISB = %00000000        'SET ALL B PORTS AS OUTPUTS
ADCON1 = %00001111    'SET ALL PORTS TO DIGITAL

MAIN:

PORTA.0 = 1
PORTA.1 = 1

DO SOME STUFF......

GOTO MAIN

PORTA.0 stays low and never changes to high. However, if I do the following, then the code works and I get both ports high.

Code:

DUMMYVAR VAR BYTE

TRISB = %00000000        'SET ALL B PORTS AS OUTPUTS
ADCON1 = %00001111    'SET ALL PORTS TO DIGITAL

MAIN:

DUMMYVAR = 3
PORTA.0 = DUMMYVAR.0 : PORTA.1 = DUMMYVAR.1

DO SOME STUFF......

GOTO MAIN

So, why does the second code works and the first one doesn't? Do you need a pause or delay when changing individual port settings in the same port bank? Does the commands HIGH and LOW resolve this issue? :confused:

Thanks,

Robert

Viewing all articles
Browse latest Browse all 4787

Trending Articles