-
Pic18 Syntax problem
hi im just begining to use the pic18 series
my current setup is:
a melabs USB programmer
PBP 2.45A
Microcode Studio 2.3.0.0
my problem is that when i try to do a really basic thing such as make portb.0 go low it doesent work properly
the following has no effect :
PORTB.0 = 0
however this works for some reson:
low PORTB.4
thanks in advance for any help and responses
-
O.K. LOW and HIGH function set the i/o of the PIC as output.
When you apply the power to the PIC, the POR(Power on Default) value set the i/o as input. You need to set it by writing to the TRISB register (se datasheet for that). Once the i/o is properly set as output you can write it as you did.
TRISB=0
PORTB.0=0
should work. TRISx is placed at the top of your code. You can Even use the OUTPUT directive wich do almost the same thing.
hth
-
exelent that worked, iv only used the pic16s up until now and was not used to needing Tris, although I was familiar with it.
I appreciate the quick response mister_e
-
Well TRISx is needed in all PIC family when you Write directly to the PORT register. You don't need the TRISx setting if you use PBP statement, HSEROUT,SERIN... HIGH, LOW...