Thanks for reply man, but it's not enough ! I am using theese two lines also
Thanks for reply man, but it's not enough ! I am using theese two lines also
Datasheet...
Section 10... let's look at this Port by Port...
PortA
Look at Table 10-2... immediately you can see you need to Disable Comparators, Voltage Reference Module and ADC's...
Jump to Comparator Module, see Register 20-1 and Figure 20-1 from those you can determine to knock-out the Comparators you don't need...
CMCON=%00000111
The Comparator has a Voltage Reference Module... jump to Register 21-1 and make sure it's OFF...
CRVCON=%00000000
Next, kill the ADC's...
Section 19 for ADC's, Register 19-1...
ADCON0=%00000000
and Register 19-2 make your selection from the table...
ADCON1=%00001111
All you're left with is configuring TRISA for your I/O application...
Now go back to Section 10 for...
PortB
Table 10-4 tells you ADC's affect this Port, but you've probably killed them with the ADCON statements you did above at PortA.
PortC
Table 10-6 tells us PortC has no issues...
PortD
Table 10-8 tells us that PortD has PWM's and a Parallel Slave Port.
By default, PWM's don't affect us - but if you want to be safe...
ECCP1CON=%00000000
A look at PSPMODE bit 4 of TRISE (OK, I didn't build this chip, so don't moan at me for having to look in TRISE for a PORTD control Bit), at Section 10-5 TRISE Register 10-1 on Page 142 tells us you need this bit to be ZERO for General Purpose I/O...
TRISE.4=0
PortE
Table 10-10 tells us that Comparators and ADC's affect this Port. But, you've probably switched them off back above at PortA stage...
OK... is there a problem?
PS, please keep problems on the forum...
Hi,
just ported a program from 16F877 to this PIC. And Port D refuses to act as an input.
I tried the following program snippet:
ECCP1CON=%00000000
TRISE.4=0
TRISD=%0001111
IF PORTD.2=1 THEN
HIGH beeper
PAUSE 1000
LOW beeper
ENDIF
I put a 1k resistor from Vdd (5V) to port D2. The beeper doesn't sound. When I change the conditional statement to "PORTD.2=0",then the beeper sounds, even with the resistor connected! I checked for shorts, and no there is no short from D2 to GND.
I also tried ports D1 and D3: same result...
For some reason ports D refuse to become input and stay output low.....
Another funny thing is that I use PortA0 as AD converter. If I connect 3V to this port, the PIC heats up like crazy (not so with the same PCB and 16F877)
When I put a 100k in series with this pin, the AD works OK and PIC doesn't heat up.
So also this pin acts as active low, even in AD mode....
Any ideas what more to try?
The following lines solved the (first) problem:
CMCON7=0
ECCP1CON=%00000000
TRISE.4=0
TRISD=%0001111
Amazing that a simple "INPUT PORTD.2" doesn't do it.
I will study the datasheet on the CMCON stuff.
thanks
Melanie,
I followed your register tutorial and ran into the following snag:
I use HSEROUT on port C6 (the hardware Tx pin) and all works fine.
However when I issue a SEROUT2 command on that pin, the pin remains silent (no activity on that pin using the oscilloscope). The very same SEROUT2 command on port A1 gives activity on the scope screen.
I assume the same applies to the SERIN2 on port C7.
What am I missing here?
Bookmarks