what did I do?
Edit:
Ohhh I see, I missed his using a goto instead of gosub.
You know why I missed this, because I never tried to run his code in hardware, so I never copied it to PBP compiler. I got lazy. Sorry
Printable View
Oh i don't think you got lazy... after maybe over 100 reply in this 63 pages and 322 replies thread (feb 05, 2007).
It was more about kidding you a little bit ;)
I really got to get me some new computer glasses, my 15' LCD @ 1024 x 768 makes this forum really hard to see, the compiler has larger fonts and brighter text. Someday a 42" monitor. Seriously mister_e I think I don't miss too much considering the first thing I programmed was in july, and all my teachers are here.
Yeah i know, seems you learn fast as well. Don't give up!
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
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
Unless you disable the analog capability... yesQuote:
Should all the analog ports be used just for analog ?
As far as i remind of this chip PORTE<2:0> have multiplex analog stuff on that you have to disable first
those will help... but better if you refer to the datasheet to make sure of everything.Code:ADCON1=7
CMCON=7
that would include port e too?
I will need to use the analog port of portA later on too...
wouldn't that disable them ? Or do I need to find anothe rport for my serin command ?
I gues i have to play around with adcon (bit 0 to 3 )
Yes indeed!
;)Quote:
Originally Posted by Datasheet section 4.5
yes yes yes not so big, ADCON1=2 works good for me
thanks
k