Hi Sayzer,
It is working, thanks I start to understand the ADCON setting
Can you point me how Tris and internal pull-up works on a 877 ?
Hi Sayzer,
It is working, thanks I start to understand the ADCON setting
Can you point me how Tris and internal pull-up works on a 877 ?
Sure.
TRISA = %00100000
Sets PORTA.5 as an input pin and all others in PORTA as output pin.
There is something here to pay attention for.
Although PORTA is 6-bit (RA0 to RA5), TRIS register uses 8-bit (0 to 7).
In this case, only right bits are considered. Thus, Bit7 and Bit6 in TRISA register are ignored ; whether they are 1 or 0 it won't matter.
TRISE = %00000000
Sets PORTE.0, PORTE.1 and PORTE.2 as output pins.
Also here, PORTE is only 3-bit (RE0 to RE2). So that, all other bits in TRISE register will be ignored.
You can also set an individual bit by,
TRISE.0=0
Sets RE0 as an output pin.
or
TRISE.0=1 sets RE0 as an input pin.
If you set a pin as analog, it must be an input pin.
For Internal Weak Pull-ups, there is a bit in OPTION_REG register.
Bit7.
OPTION_REG.7 is PORTB Pull-up Enable bit
OPTION_REG.7 = 1
PORTB pull-ups are disabled.
OPTION_REG.7 = 0
PORTB pull-ups are enabled by individual port latch values.
Once you set this bit as 0 then you can have weak pull ups on PORTB pins that were set to be input pins beforehand.
-----------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Ok fine,
Understood, so PORTB has only the weak pull-up feature ?
another question concerning HSERIN
I'm using a 16f877 with max 232 at 4mhz
I'm having problems reading multiple variables in 1 serin string
It works, but after some times it hangs so I think there is a buffer overflow
What worries me is that when i measure with an osciloscope, there are pulses on portc.7 the UART RX even with no max232 chip connected ???
Here is a part of the code:
DEFINE HSER_RCSTA 90h ' enable serial port,
' enable continuous receive
'
define HSER_TXSTA 24h ' enable transmit,
' BRGH=1
'
define HSER_SPBRG 103 ' set baudrate to 2400
DEFINE HSER_CLOERR 1 ' automatic clear overrun error
TRISB = %00000000
'OPTION_REG.7 = 0 ' Enable PORTB pullups
TRISC = %10000000
TRISD = %00001111
TRISE = %000
loop:
Hserin 500,LCD,[wait ("TAR"),dec3 var1,wait ("ANT"),DEC3 var2,wait ("AUX"),DEC3 var3,wait ("EXT"),DEC3 var4]
LCD:
pause 10
Lcdout $fe, 1 ' Clear screen
Lcdout "VAR1: ",#VAR1," VAR2: ",#var2
Lcdout $fe, $c0, "VAR3: ",#VAR3," VAR4:",#VAR4
Goto loop
Any Idea ?
Hi RF,
I do not have much experience in serin/serout commands.
I may mislead you with some incorrect or never tried advices.
But, at first look, I am not sure whether you can use more then one "WAIT" in one serin command or not.
I believe another member with valuable and reliable Serin/Serout experiences will respond.
----------------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Bookmarks