PORTA register won't bit set (MPLAB)

When I execute my simple program in MPLAB the PORTA filer register bit 0 is not being set, but I can easily set bit 0 of the FSR register that sits right next to PORTA in the micro. In fact, nothing I do to PORTA works. Has anyone seen this before?

Start BSF STATUS, RP0 MOVLW B'11111110' BCF STATUS, RP0

BSF PORTA, 0 ;doesn't work BSF FSR, 0 ;works

Thanks, Thomas

Reply to
Thomas Magma
Loading thread data ...

is

as

porta is analoge by default, you need to set it to digital.

Reply to
cbarn24050

What is the purpose of the first three lines? And why do you change RP0 before and after the MOVLW? Doesn't make sense...

Maybe you meant to do this:

START BSF STATUS,RP0 MOVLW B'11111110' MOVWF TRISA BCF STATUS,RP0

BSF PORTA,0 ...

Some PICs have analogue inputs (for comparator/ADC modules) multiplexed with port A, in which case you need to disable these modules to use port A for general I/O. See the PIC's data sheet.

--
Regards,
Costas
 Click to see the full signature
Reply to
Costas Vlachos

porta is analoge by default, you need to set it to digital.

Thanks! That was it.

Reply to
Thomas Magma

Hi Thomas,

Also ideally you need to be writing to LATB instead of PORTB. Of course you

*can* write to PORTB but it's a bad practice to get into. It can create headaches and quite mysterious behaviour as you become more advanced.

Remember.. Writes to the latch, Reads from the port.

There's alot of information regarding this topic;

formatting link
Lots of good info on the Microchip Forum too. Be concise with them on there because if you give the impression that you're not trying at all or haven't read the manual, well, you'll get the hang on it. :)

Good luck :)

Reply to
Alison

Is RP1 = 0? PortA is only in bank 0 and you may be switching between banks 2 and 3 with your code.

Mike.

Reply to
NewsGroup

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.