View previous topic :: View next topic |
Author |
Message |
Robert_d1968
Joined: 18 Dec 2012 Posts: 67 Location: America
|
Posted: Sun Jan 08, 2017 10:15 am Post subject: ATmega88 and adc problem *SOLVED* |
|
|
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 |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Sun Jan 08, 2017 10:42 am Post subject: |
|
|
Hi ,
Read the datasheet, ATmega 88 has not PORTC.7 and PORTC.6 is use for reset
JP |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Jan 08, 2017 10:53 am Post subject: Re: ATmega88 and adc problem |
|
|
Robert_d1968 wrote: | Can port C be used like that? | Sure.
Connect AVCC. |
|
Back to top |
|
|
Robert_d1968
Joined: 18 Dec 2012 Posts: 67 Location: America
|
Posted: Sun Jan 08, 2017 11:16 am Post subject: |
|
|
Thanks for the pointer,
I did check the datasheet and you are correct.
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 |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Sun Jan 08, 2017 1:38 pm Post subject: |
|
|
Mega328P in 32 pins TQFP package have ADC6 and ADC7 on their dedicated pins but they can not be outputs |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Sun Jan 08, 2017 3:15 pm Post subject: |
|
|
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
|
|
Back to top |
|
|
|