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 multiple sensor interfacing problem

Status
Not open for further replies.

szak1592

Newbie level 1
Joined
Nov 24, 2014
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
0
Activity points
0
I have interfaced a single sensor and the code works, but when I try to interface two sensors at the same time, the simulation does not work at all. Please check the code and the simulation schematic in proteus and let me know what is wrong in the code. Here is the link to the proteus schematic screenshot
**broken link removed**

#define F_CPU 4000000UL
#include <avr/io.h>
#include <avr/interrupt.h>


int main(void)
{
DDRC = 0xff;
DDRD = 0xff;
DDRA = 0x00;

ADMUX=0x00;
//ADMUX |= 1<<REFS0 | 1<<REFS1;
ADCSRA |= 1<<ADIE;
ADCSRA |= 1<<ADEN;

sei();

ADCSRA |= 1<<ADSC;

while (1);
return 0;
}
ISR(ADC_vect)
{

uint16_t adc_value;
uint16_t adc_value_2;
switch (ADMUX) {
case (0xC0):
// ADCSRA |= (1<<(ADSC));
// while ((ADCSRA &(1<<ADIF))==0);
adc_value=ADC;

if (adc_value<512)
{
PORTC = PORTC & 0b11111110;
}
else
{
PORTC = PORTC | 0b00000001;
}
//ADMUX = 0xE1;
break;



case (0xC1):
adc_value_2=ADC;

if (adc_value<512)
{
PORTC = PORTC & 0b11111101;
}
else
{
PORTC = PORTC | 0b00000010;
}
//ADMUX = 0xE1;
break;


default:
break; }

ADCSRA |= 1<<ADSC;


}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top