ECIO+LCDportA+Analoge+pull-up

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
D.Bouchier
Posts: 28
Joined: Tue Sep 28, 2010 12:36 pm
Has thanked: 5 times
Been thanked: 1 time
Contact:

ECIO+LCDportA+Analoge+pull-up

Post by D.Bouchier »

Weird titel...

What I mean is;
Im using a ECIO40 (18f4455) with application board, LCD E-block on port A, I want to use analoge inputs aswell as digital inputs with internal pull-up resistors on portB.

Now there are some problems:
I know you have to make "adcon0 = 0x30;" in order for the LCD to work on porta.
I know you have to make "intcon2 &= 0x7f;" to enable the pull-ups.
I've read that the internal pull-ups of analoge inputs get disabled.

But using this all together won't work very well, I can get the the 2 seperate halfs work, but not together, I'm probly doing some registers wrong, some help over here please?

Thanks in advance,
Dominique

D.Bouchier
Posts: 28
Joined: Tue Sep 28, 2010 12:36 pm
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: ECIO+LCDportA+Analoge+pull-up

Post by D.Bouchier »

Anyone feels like having thew knowledge to help me out here?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO+LCDportA+Analoge+pull-up

Post by Benj »

Hello,

What is happening when you try to use both together? Is the LCD failing or is it the pull ups?

I think to enable the pull up resistors you should instead be using this line of code.

intcon2 = intcon2 & 0x7F;

I try not to use |= and &= statements as earlier versions of BoostC compiled correctly but did not work correctly when writing code like this.

Maybe worth customizing the ADC sample function and adding the line there to see if it is the sample that is doing something

D.Bouchier
Posts: 28
Joined: Tue Sep 28, 2010 12:36 pm
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: ECIO+LCDportA+Analoge+pull-up

Post by D.Bouchier »

"What is happening when you try to use both together? Is the LCD failing or is it the pull ups?"

It where the pull-ups that where not working.

With intcon2 = intcon2 & 0x7F; it works as intended, thank you very much

D.Bouchier
Posts: 28
Joined: Tue Sep 28, 2010 12:36 pm
Has thanked: 5 times
Been thanked: 1 time
Contact:

Re: ECIO+LCDportA+Analoge+pull-up

Post by D.Bouchier »

Hello again,

I have been progressing with this project and stumbled on new found problems closely related to my previous one.

I got the LCD working on portA
I got the pull-ups working on portB
I got the ADC channels 10,11 and 12 (on portB) working
But the other ADC channels on this port always return 254

I use this to initialize:
adcon0 = 0xf1;
intcon2 = intcon2 & 0x7f;

I know adcon0 = 0xf1;
selects an unimplemented adc channel but flowcode selects the channel with the macro anyway.
It also does not work if I change adcon0 so that it enables a channel that i can't get to work.

it's not required, because i could use channel 10,11 and 12 but id like to use channel 8 aswell.

any idea why the remaining channels on portB act different then 10,11 and 12?

Greetings

Edit:
I found how they are different, I first make the pin high to charge an external capacitor and then make a voltage division between the Cext and the Chold from the ADC to determine the Cext value. appearndly driving the pin of channel 10,11 and 12 high, doesnt charge the Chold if you make a ADC conversion, but on the other channels it does.
I solved this by making the ADC channel an input after Cext charging and before ADC conversion, works as a train now, sorry for the unneeded post.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ECIO+LCDportA+Analoge+pull-up

Post by Benj »

Hello,

Great to hear you got it working and many thanks for posting the workaround to the problem.

Post Reply