PDA

View Full Version : Someone please help me out?



avanomi
- 19th July 2013, 02:03
First of all Hi, I'm new. Glad to meet you people.

I am an extreme newbie here. I cannot for the life of me figure this out properly.

I opened the example lcdx for PIC16F877A but I'm stupid, so I wanted to try to compile it for another PIC chip. PIC16F87 to be specific. I'm looking at the datasheet, and found ADCS1 in special register functions.

So naturally, I thought it would just compile for it, but these lines stop the compilation.


ADCS1 = 7 ' Set PORTA and PORTE to digital
Low PORTE.2


It says:
For ADCS1 = 7:

Bad Expression

For Low PORTE.2

Syntax Error I think...
Could someone explain to me how this works? I am so confused honestly.

Could someone point me at an instruction set thinger for specific microcontrollers?

Archangel
- 19th July 2013, 03:10
Hello avanomi & welcome,
ADCS1 is bit 7 of the ADCON0 register, you would " set " this bit as ADCON0.7 = 1 or ADCON0 = %10000000 Microchip Data sheet PP 129 .

What it appears you are trying to do is to Disable the Synchronous Serial Port and use Port A as Digital I/O.
Data sheet PP 83/84 SSPCON register bit 5 enables / disables SSP set it to zero and you are golden. Remember this chip has several
Analog registers which have to be set to get digital I/O. ADCON0, ADCON1, ADRESH ADRESL . . . see page 43 for PortA registers, DO Use the index
of the Data Sheet under registers.
HTH
EDIT:
Page numbers could be off a bit due to Adobe reader showing different number from printed page, but close.
EDIT EDIT: PortE ADCON1, TRISE 0:2 For port E, watch out for TRISE.4 if set will upset PortD's use as I/O. PP50:52

avanomi
- 19th July 2013, 03:39
Wow thanks, I feel like an idiot for 2 reasons, 1) Your explanation made sense. 2) Usually the new post is at the bottom, so I was reading my own post for a few minutes thinking you quoted it. lol

Edit:
I'm still a bit confused on the Low PORTE.2 part.

Edit 2:
Does ADCON stand for Analogue Digital Converter? (Wild Guess)

Archangel
- 19th July 2013, 04:09
First off . . . We've all been there, sometimes I spend a great deal of time there (feeling . . . )
LOW command automatically sets the TRIS and Port registers for you, as far as I know it does not set the analog registers for you, I am not sure as I virtually never use it.
ADCON is A/D Converter register, some chips do not use it as they have no A/D converters I E 16F628A has analog comparators but no ADCON.