Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AVR ADC question, please help

Status
Not open for further replies.

MohammadElwakeel

Junior Member level 1
Joined
Feb 18, 2007
Messages
18
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,441
avr adc interrupt

Hi all,

I'm currently using ATMEGA16 and I have a question concerning ADC. Can I use

some pins of PORTA for the ADC and in the same time use other pins of that port

for digital input output. i.e. can PORTA be used as mixed port for analog and

digital inputs??

Please help ASAP!!!
 

avr adc temperature

Hi!
Of coures you can do that. For this purpose use the ADMUX register.
You can select the channel that is connected to the ADC. Only the selected channel will become an analog input and the rest of the pins will remain digital I/O's with their functionality controlled by the corresponding data direction register.

Regards.
 
avr adc an

see this code, you will understand how to use internal ADC
**broken link removed**

Bibin John
www.bibinjohn.tk
 

You can program each port as you want to.
search for more information the internal structure of the ADC
 

this code its working
include <mega8535.h>
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd.h>
#include <delay.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include<stdio.h>

float current_temp;
float voltage;
char lcdbuffer[16];

//ADC interrupt service routine
interrupt [ADC_INT] void adc_isr(void)
{
unsigned int ADC_DATA;
ADC_DATA=ADCW; // get data from ADC
voltage=((float)4680*(float)ADC_DATA)/(float)1023;
ADCSRA=ADCSRA|0x40;
}

void temp()
{
current_temp=0.1*voltage+2.0;
ftoa(current_temp,2,lcdbuffer);
lcd_gotoxy(8,0);
lcd_puts(lcdbuffer);
}

void main(void)
{
lcd_init(16); // LCD Initialization.
ADMUX=0x01;
ADCSRA=0xAC;
SFIOR&=0x0F;
lcd_gotoxy(0,0);
lcd_putsf("Temp:");
while (1)
{
#asm ("sei")

temp();
};
}
 

no i dont think so . as i know when u config ADC u are NOT be able to use the same port as I/O pin.

(reference :Atmel COP. datasheets)
 

Yes U can use remaining pin as digital I/O.


In 7th SEM I have made AVR based temperature controller using ATmega8535 and LM35(temperature sensor).

The code for ADC config. is as under.

void adcfg(void)
{
ADCSRA=0xAD;// ADC triggered at every TIM 0 overflow with interrupt enabled
SFIOR&=0x0F;
SFIOR|=0x80;
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top