EmbeddedRelated.com
Forums
Memfault Beyond the Launch

PORTA register won't bit set (MPLAB)

Started by Thomas Magma November 22, 2006
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 



On Nov 22, 7:48=A0pm, "Thomas Magma" <somewh...@overtherainbow.com>
wrote:
> 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. H=
as
> anyone seen this before? > > Start =A0 =A0 BSF STATUS, RP0 > =A0 =A0 =A0 =A0 =A0 =A0 MOVLW B'11111110' > =A0 =A0 =A0 =A0 =A0 =A0 BCF STATUS, RP0 > > =A0 =A0 =A0 =A0 =A0 =A0 BSF PORTA, 0 =A0 =A0 ;doesn't work > =A0 =A0 =A0 =A0 =A0 =A0 BSF FSR, 0 =A0 =A0 =A0 =A0 =A0 ;works > > Thanks, > Thomas
porta is analoge by default, you need to set it to digital.
Thomas Magma wrote:
> 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
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 _________________________________________________ Costas Vlachos Email: c-X-vlachos@hot-X-mail.com SPAM-TRAPPED: Please remove "-X-" before replying
<cbarn24050@aol.com> wrote in message 
news:1164225410.622053.308300@j44g2000cwa.googlegroups.com...


On Nov 22, 7:48pm, "Thomas Magma" <somewh...@overtherainbow.com>
wrote:
> 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
porta is analoge by default, you need to set it to digital. Thanks! That was it.
Thomas Magma <somewhere@overtherainbow.com> wrote in message
news:sm29h.345126$1T2.95425@pd7urf2no...
> > > > > Start BSF STATUS, RP0 > > MOVLW B'11111110' > > BCF STATUS, RP0 > > > > BSF PORTA, 0 ;doesn't work > > BSF FSR, 0 ;works > >
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; http://forum.microchip.com/tm.aspx?m=193612 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 :)
Is RP1 = 0? PortA is only in bank 0 and you may be switching between banks 2 
and 3 with your code.

Mike.

"Thomas Magma" <somewhere@overtherainbow.com> wrote in message 
news:qQ19h.345033$1T2.48459@pd7urf2no...
> 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 >

Memfault Beyond the Launch