HI,
how the heck do you disable portE.2 on a pic16F877a. I would like to use it as a serin pin. I would like to disable the parallel slave port, and make use of the serin command. The serin command works for portB fine.
thanks
HI,
how the heck do you disable portE.2 on a pic16F877a. I would like to use it as a serin pin. I would like to disable the parallel slave port, and make use of the serin command. The serin command works for portB fine.
thanks
What do you mean disable portE.2?
If you're talking about disabling the whole parallel slave port (driven using Port D), then set TRISE.4 = 0 (it's in the datasheet, Section 4.5, Page 50 I think).
P.S. Are we going for some sort of record on this thread? Because it's covered a LOT of subjects so far (wireless, A/D, I2C, math, etc.etc).
well basically I use this command:
serin portB.2 = works
serin portE.2 = do not work
I set them both as input.
All my B ports are taken up already.
It's not set up as an analog port is it?
Maybe you set TRISE as $FF instead of %00000111. If you did, bit 4 will change Port E into control for the PBP.
But, again, I'm probably pointing out the obvious to you...
Have you tried just setting the pin high and low and reading it and seeing what happens?
Well here is the program that works:
but changing portb.2 to porte.2
it do not work.
INCLUDE "modedefs.bas"
@ DEVICE PIC16F877a , HS_OSC , WDT_OFF , PWRT_ON , BOD_ON , LVP_OFF , PROTECT_OFF
'HS 20mhz, watchdog off, powerup timer on, mclr external, brown out detect on, low volt program off , code protect off
DEFINE OSC 20 'use external 20mhz crystal
DEFINE LCD_DREG PORTD ' Set LCD Data port
DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTC ' Set LCD Register Select port
DEFINE LCD_RSBIT 6 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTC ' Set LCD Enable port
DEFINE LCD_EBIT 7 ' Set LCD Enable bit ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2500
DEFINE LCD_DATAUS 250
DEFINE CHAR_PACING 2000
Pause 2000 ' Wait 2 second
TRISA = %11111111 ' Set PORTA to all input
TRISB = %00111111
TRISC = %00010000
TRISD = %00000000
TRISE = %00000111
right var byte : left var byte
temp var word : counter var byte
rightold var word : leftold var word : speedright var byte : speedleft var byte
'************************************************* ***************************************
loop:
portb.7 =1
pause 100
portb.6 =1
pause 100
waitfor55:
serin portb.2 , n2400 , temp : if temp <> $55 then goto waitfor55
waitforaa:
serin portb.2 , n2400 , temp : if temp <> $aa then goto waitforaa
serin portb.2, n2400, rightold.LowBYTE : serin portb.2, n2400, rightold.HighBYTE
serin portb.2, n2400, leftold.LowBYTE : serin portb.2, n2400, leftold.HighBYTE
For counter=0 TO 7 'decoding
right.0[counter]=rightold.0[counter*2]
left.0[counter]=leftold.0[counter*2]
Next counter
Lcdout $fe, 1 'Clear screen
Lcdout "Left: ", Dec left
Lcdout $fe, $C0, "Right: ", Dec right
Pause 100
goto loop
end
Last edited by lerameur; - 6th February 2007 at 02:30.
no does not work
I tried other B port and they work.
I tried the analog ports like porta.0 and does not work.
Should all the analog ports be used just for analog ?
k
Bookmarks