gnupic: Failing to Read PORTA on 16F627, but works on 16F84.
Subject:
Re: Failing to Read PORTA on 16F627, but works on 16F84.
From:
Scott Dattalo ####@####.####
Date:
16 Dec 2001 15:13:51 -0000
Message-Id: <Pine.LNX.4.33.0112160709510.16706-100000@ruckus.brouhaha.com>
On Sun, 16 Dec 2001, Simon Wood wrote:
> Hi all,
> I'm hoping that some here can spot the obvious mistake in my code... I've
> spent about a week trying things and not seeing what's going wrong. As the
> subject says this code works on a 16F84 but not on a 16F627 (which I would
> prefer to use as they're a lot cheaper).
>
> The code is monitoring a propriority serial bus and is supposed to detect
> a low period of >6ms on the data pin (PORTA, 1) and then 2ms after this
> pin goes high it forces it low for 4ms. This signals the serial bus
> controller that the slave (my code) has some information to pass it.
>
> I have a work-around which just relies on the fact I know that data will
> only be low for 8ms, but I don't like to do this as it is a NASTY_HACK.
>
> I set up PORTA earlier in the code as:
> IFDEF PIC_16
> bcf STATUS, RP0
>
> IFDEF PIC_16F627
> bcf STATUS, RP1
> ENDIF
>
> clrf PORTA
>
> IFDEF PIC_16F627
> movlw 0x07 ; Disable the Comparitors
> movwf CMCON
> ENDIF
I'd make sure the Comparators are really being disabled in the above
snippet. I had a similar problem on a '622 on one occasion and it turned
out that Porta was just not being set up properly. Try a simple program
with just initializing PORTA and blinking an LED.
Scott