Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ATmega88 and adc problem *SOLVED*

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Robert_d1968

Bascom Member



Joined: 18 Dec 2012
Posts: 64
Location: China

usa.gif
PostPosted: Sun Jan 08, 2017 10:15 am    Post subject: ATmega88 and adc problem *SOLVED* Reply with quote

Hello everybody,

I'm using an ATmega88 for debug reasons (OCD). I set up the ADC to have one output PORTC.7 and one input on PORTC.2

The rest of portc is used for ADC readings.

Code:
Config Portb.6 = Output                                     '- Set PORTB.6 as Outputs B1 red/green
Config Portb.7 = Output                                     '- Set PORTB.7 as Output  B1 red/green
Config Portc.0 = Input                                      '- Set PORTC.0 as Input
Config Portc.1 = Input                                      '- Set PORTC.1 as Input
Config Portc.2 = Input                                      '- Set PORTC.2 as Input (Kit switch)
Config Portc.3 = Input                                      '- Set PORTC.3 as Input
Config Portc.4 = Input                                      '- Set PORTC.3 as Input
Config Portc.5 = Input                                      '- Set PORTC.5 as Input
Config Portc.6 = Input                                      '- Set PORTC.6 as Input (Printer current)
Config Portc.7 = Output                                     '- Set PORTC.7 as Output (Main battery relay)


I just set them up like this, but I can't get PORTC.7 be switched to the on state, for that matter even If I change other inputs to be outputs. I also can't switch their states as well.

But I can read a switch that is connected via PORTC.2 in the software, and the rest of the ADC readings work as well.

Can port C be used like that? IE. setup inputs and outputs and still use the other ADC channels of PORTC ?

I tried this on another ATmega88 and It does the same thing. Any Ideas?

Thanks for any help you can provide,

Robert

(BASCOM-AVR version : 2.0.7.8 )


Last edited by Robert_d1968 on Sun Jan 08, 2017 11:17 am; edited 1 time in total
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 923
Location: France

france.gif
PostPosted: Sun Jan 08, 2017 10:42 am    Post subject: Reply with quote

Hi ,
Read the datasheet, ATmega 88 has not PORTC.7 and PORTC.6 is use for reset
JP
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1803

blank.gif
PostPosted: Sun Jan 08, 2017 10:53 am    Post subject: Re: ATmega88 and adc problem Reply with quote

Robert_d1968 wrote:
Can port C be used like that?
Sure.
Quote:
Any Ideas?
Connect AVCC.
Back to top
View user's profile
Robert_d1968

Bascom Member



Joined: 18 Dec 2012
Posts: 64
Location: China

usa.gif
PostPosted: Sun Jan 08, 2017 11:16 am    Post subject: Reply with quote

Thanks for the pointer,

I did check the datasheet and you are correct. Sad

I guess I will just switch to the atmega128 instead, as I still need a lil more I/O.

Thanks for the help,

Robert
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 676

poland.gif
PostPosted: Sun Jan 08, 2017 1:38 pm    Post subject: Reply with quote

Mega328P in 32 pins TQFP package have ADC6 and ADC7 on their dedicated pins but they can not be outputs Very Happy
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 923
Location: France

france.gif
PostPosted: Sun Jan 08, 2017 3:15 pm    Post subject: Reply with quote

you can find a lot of "Arduino 2560 like" at very good price with a lot of ADC port (16)

now I use
Tiny 85
mega 328 p (arduino)
mega 2560 arduino too
they are 5V compatible

they cover all my needs

unfortunately, AFAK, it is difficult to find Xmega on printed circuit and they are 3.3V only so you need to convert all your signals
JP
Wink
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum