Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

RE: [AVR-Chat] Can you have split ADC usage

RE: [AVR-Chat] Can you have split ADC usage

2013-05-14 by Dave McLaughlin

Yes. 

 

All setup and code to read the ADC should work.

 

If this fails I may switch to using an Arduino with the Mega328 as I can debug this via the debug wire interface.

 

That way I don't have any issues with ADC and digital on the same port.

 

 

Dave…
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of Cat C
Sent: 14 May 2013 14:57
To: AVR-Chat@yahoogroups.com
Subject: RE: [AVR-Chat] Can you have split ADC usage

 

  

Did you set up the MUX?
Cat

-----Original Message-----

From: Dave McLaughlin
Sent: 14 May 2013 02:23:42 GMT
To: AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com> 
Subject: [AVR-Chat] Can you have split ADC usage

Hi all,

I have a small board from another project that only has PA0 to PA5 of an
ATMega324P brought out and I need to do the following:

1 pulse input (PA0/INT0)

2 ADC input (PA1 and PA2)

1 digital output (PA3)

I2C bus (PA4 and PA5)

Is it possible to use the ADC on PortA on only 2 channels, ie mixed digital
and analog like this?

I have tried but the 2 ADC channels (1 and 2) are always returning a 1023
bit reading.

I have disabled the digital on those 2 channels.

Is this at all possible or am I going to have to build a small external ADC
board to do this over I2C?

Dave.

---

Very funny Scotty, now beam down my clothes.

---

[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links




 <http://groups.yahoo.com/group/AVR-Chat/post;_ylc=X3oDMTJxdnFjdXRqBF9TAzk3MzU5NzE0BGdycElkAzQzMTM5NzQEZ3Jwc3BJZAMxNzA2NTU0MjA1BG1zZ0lkAzE4NDc2BHNlYwNmdHIEc2xrA3JwbHkEc3RpbWUDMTM2ODUxNDcyMw--?act=reply&messageNum=18476> Reply via web post 

 <mailto:catalin_cluj@hotmail.com?subject=RE%3A%20%5BAVR-Chat%5D%20Can%20you%20have%20split%20ADC%20usage> Reply to sender 

 <mailto:AVR-Chat@yahoogroups.com?subject=RE%3A%20%5BAVR-Chat%5D%20Can%20you%20have%20split%20ADC%20usage> Reply to group 

 <http://groups.yahoo.com/group/AVR-Chat/post;_ylc=X3oDMTJlZjg2YXZxBF9TAzk3MzU5NzE0BGdycElkAzQzMTM5NzQEZ3Jwc3BJZAMxNzA2NTU0MjA1BHNlYwNmdHIEc2xrA250cGMEc3RpbWUDMTM2ODUxNDcyMw--> Start a New Topic 

 <http://groups.yahoo.com/group/AVR-Chat/message/18473;_ylc=X3oDMTM2ZzBlYWw2BF9TAzk3MzU5NzE0BGdycElkAzQzMTM5NzQEZ3Jwc3BJZAMxNzA2NTU0MjA1BG1zZ0lkAzE4NDc2BHNlYwNmdHIEc2xrA3Z0cGMEc3RpbWUDMTM2ODUxNDcyMwR0cGNJZAMxODQ3Mw--> Messages in this topic (4) 

Recent Activity: 

 <http://groups.yahoo.com/group/AVR-Chat;_ylc=X3oDMTJlMXU5MGhyBF9TAzk3MzU5NzE0BGdycElkAzQzMTM5NzQEZ3Jwc3BJZAMxNzA2NTU0MjA1BHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTM2ODUxNDcyMw--> Visit Your Group 

 <http://groups.yahoo.com/;_ylc=X3oDMTJkcmJtZjZlBF9TAzk3MzU5NzE0BGdycElkAzQzMTM5NzQEZ3Jwc3BJZAMxNzA2NTU0MjA1BHNlYwNmdHIEc2xrA2dmcARzdGltZQMxMzY4NTE0NzIz> Image removed by sender. Yahoo! Groups

Switch to:  <mailto:AVR-Chat-traditional@yahoogroups.com?subject=Change%20Delivery%20Format:%20Traditional> Text-Only,  <mailto:AVR-Chat-digest@yahoogroups.com?subject=Email%20Delivery:%20Digest> Daily Digest •  <mailto:AVR-Chat-unsubscribe@yahoogroups.com?subject=Unsubscribe> Unsubscribe •  <http://docs.yahoo.com/info/terms/> Terms of Use •  <mailto:ygroupsnotifications@yahoogroups.com?subject=Feedback%20on%20the%20redesigned%20individual%20mail%20v1> Send us Feedback 



[Non-text portions of this message have been removed]

RE: [AVR-Chat] Can you have split ADC usage

2013-05-14 by John Samperi

At 05:06 PM 14/05/2013, you wrote:
>If this fails I may switch to using an Arduino with the Mega328 as I 
>can debug this via the debug wire interface.

Don't you have JTAG set up with the Mega324?

Also:

>I2C bus (PA4 and PA5)

Any reason why you can't use the REAL I2C/TWI pins on PORTC 0 and 1?
(Maybe already in use??)

Maybe you can post your init code, I use both analog and digital inputs
on PORTA on a board I use for odds and ends with the Mega164p/324p/644p chip.

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

RE: [AVR-Chat] Can you have split ADC usage

2013-05-14 by Cat C

Did you set up the MUX?
Cat
Show quoted textHide quoted text
-----Original Message-----

From: Dave McLaughlin
Sent: 14 May 2013 02:23:42 GMT
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] Can you have split ADC usage

Hi all,



I have a small board from another project that only has PA0 to PA5 of an
ATMega324P brought out and I need to do the following:



1 pulse input (PA0/INT0)

2 ADC input (PA1 and PA2)

1 digital output (PA3)

I2C bus (PA4 and PA5)



Is it possible to use the ADC on PortA on only 2 channels, ie mixed digital
and analog like this?



I have tried but the 2 ADC channels (1 and 2) are always returning a 1023
bit reading.



I have disabled the digital on those 2 channels.





Is this at all possible or am I going to have to build a small external ADC
board to do this over I2C?





Dave.

---

Very funny Scotty, now beam down my clothes.

---





[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links

Re: [AVR-Chat] Can you have split ADC usage

2013-05-14 by enkitec@gmail.com

Did you start up the ADC?

     Mark
Show quoted textHide quoted text
On 14-May-13 04:56, Cat C wrote:
> Did you set up the MUX?
> Cat
>
> -----Original Message-----
>
> From: Dave McLaughlin
> Sent: 14 May 2013 02:23:42 GMT
> To: AVR-Chat@yahoogroups.com
> Subject: [AVR-Chat] Can you have split ADC usage
>
> Hi all,
>
>
>
> I have a small board from another project that only has PA0 to PA5 of an
> ATMega324P brought out and I need to do the following:
>
>
>
> 1 pulse input (PA0/INT0)
>
> 2 ADC input (PA1 and PA2)
>
> 1 digital output (PA3)
>
> I2C bus (PA4 and PA5)
>
>
>
> Is it possible to use the ADC on PortA on only 2 channels, ie mixed digital
> and analog like this?
>
>
>
> I have tried but the 2 ADC channels (1 and 2) are always returning a 1023
> bit reading.
>
>
>
> I have disabled the digital on those 2 channels.
>
>
>
>
>
> Is this at all possible or am I going to have to build a small external ADC
> board to do this over I2C?
>
>
>
>
>
> Dave.
>
> ---
>
> Very funny Scotty, now beam down my clothes.
>
> ---
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
> .
>

RE: [AVR-Chat] Can you have split ADC usage

2013-05-14 by Dave McLaughlin

This is the init code. I have a licensed copy of Codevision so I took some of the init code from that to build the AVR GCC programme. I needed 64 bit long for the Zigbee to work and right now, Codevision does not support it :)

 

#define ADC_VREF_TYPE ((0<<REFS1) | (1<<REFS0) | (0<<ADLAR))

 

Here is the init code for the ADC

 

       // ADC initialization

       // ADC Clock frequency: 250.000 kHz

       // ADC Voltage Reference: AVCC pin

       // ADC Auto Trigger Source: ADC Stopped

       // Digital input buffers on ADC0: On, ADC1: Off, ADC2: Off, ADC3: On

       // ADC4: On, ADC5: On, ADC6: On, ADC7: On

       DIDR0=(0<<ADC7D) | (0<<ADC6D) | (0<<ADC5D) | (0<<ADC4D) | (0<<ADC3D) | (1<<ADC2D) | (1<<ADC1D) | (0<<ADC0D);

       ADMUX=ADC_VREF_TYPE;

       ADCSRA=(1<<ADEN) | (0<<ADSC) | (0<<ADATE) | (0<<ADIF) | (0<<ADIE) | (1<<ADPS2) | (1<<ADPS1) | (0<<ADPS0);

       ADCSRB=(0<<ADTS2) | (0<<ADTS1) | (0<<ADTS0);

 

 

Then this is used to read the ADC

 

unsigned int ReadADC(unsigned char adc_input)

{

       ADMUX=adc_input | ADC_VREF_TYPE;

       // Delay needed for the stabilization of the ADC input voltage

       _delay_us(10);

       // Start the AD conversion

       ADCSRA|=(1<<ADSC);

       // Wait for the AD conversion to complete

       while ((ADCSRA & (1<<ADIF))==0);

       ADCSRA|=(1<<ADIF);

       return ADCW;

}

 

 

Dave…
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of enkitec@gmail.com
Sent: 14 May 2013 18:28
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Can you have split ADC usage

 

  


Did you start up the ADC?

Mark

On 14-May-13 04:56, Cat C wrote:
> Did you set up the MUX?
> Cat





[Non-text portions of this message have been removed]

RE: [AVR-Chat] Can you have split ADC usage

2013-05-14 by Dave McLaughlin

This is the init code. I have a licensed copy of Codevision so I took some of the init code from that to build the AVR GCC programme. I needed 64 bit long for the Zigbee to work and right now, Codevision does not support it :)

 

#define ADC_VREF_TYPE ((0<<REFS1) | (1<<REFS0) | (0<<ADLAR))

 

Here is the init code for the ADC

 

       // ADC initialization

       // ADC Clock frequency: 250.000 kHz

       // ADC Voltage Reference: AVCC pin

       // ADC Auto Trigger Source: ADC Stopped

       // Digital input buffers on ADC0: On, ADC1: Off, ADC2: Off, ADC3: On

       // ADC4: On, ADC5: On, ADC6: On, ADC7: On

       DIDR0=(0<<ADC7D) | (0<<ADC6D) | (0<<ADC5D) | (0<<ADC4D) | (0<<ADC3D) | (1<<ADC2D) | (1<<ADC1D) | (0<<ADC0D);

       ADMUX=ADC_VREF_TYPE;

       ADCSRA=(1<<ADEN) | (0<<ADSC) | (0<<ADATE) | (0<<ADIF) | (0<<ADIE) | (1<<ADPS2) | (1<<ADPS1) | (0<<ADPS0);

       ADCSRB=(0<<ADTS2) | (0<<ADTS1) | (0<<ADTS0);

 

 

Then this is used to read the ADC

 

unsigned int ReadADC(unsigned char adc_input)

{

       ADMUX=adc_input | ADC_VREF_TYPE;

       // Delay needed for the stabilization of the ADC input voltage

       _delay_us(10);

       // Start the AD conversion

       ADCSRA|=(1<<ADSC);

       // Wait for the AD conversion to complete

       while ((ADCSRA & (1<<ADIF))==0);

       ADCSRA|=(1<<ADIF);

       return ADCW;

}

 

 

Dave…
Show quoted textHide quoted text
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of enkitec@gmail.com
Sent: 14 May 2013 18:28
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Can you have split ADC usage

 

  


Did you start up the ADC?

Mark

On 14-May-13 04:56, Cat C wrote:
> Did you set up the MUX?
> Cat





[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.