standalone Atmega controller

hi guys im working on a servo control project with knob but here im using a standalone Atmega controller to get my job done

im using Atmega 1281 processor

my main problem is the ADC process of this controller
here is my code

i want the ADC to work in Free Running Mode to read the POT value and control the micro servo in PWM but in proteus the ADC ports wont get enabled

what might be the problem ?

help is appreciated alot

note :- this code works perfectly on a ATmega8 controller

thanks

#define F_CPU 16000000 //16MHz
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdlib.h>

//#include <stdio.h>
//#include "uart/uart.h"


#define PWM_PRESCALLER 64
#define ICR_MAX (long double)F_CPU/PWM_PRESCALLER/50
#define OCR_MIN ICR_MAX/20
#define OCR_MAX ICR_MAX/10

//char uart_s[150];
volatile unsigned long adc_val=0;
volatile unsigned long counter=0;
unsigned long curr_adc=0;

ISR (ADC_vect)
{
	adc_val += ADC;
	counter++;
}

int main(void)
{
	//uart_init(uart_calc_ubrr(F_CPU));
	
	DDRB |= (1<<DDB1);
	
	ICR1 = ICR_MAX;
	OCR1A = OCR_MIN;
	TCCR1A = (1 << COM1A1) | (1<<WGM11);
	TCCR1B = (1<<WGM13) | (1<<WGM12) | (1<<CS11) | (1<<CS10);
	
	
	
	ADMUX = (1 << REFS0);
	ADCSRA = (1 << ADEN)|(1 << ADATE)|(1 << ADIE)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
	
	sei();
	
	ADCSRA |= (1<<ADSC);
	


	while(1)
	{
		if(counter >= 500)
		{
			cli();
			
			unsigned long round_val = round(adc_val / counter);
			
			adc_val=0;
			counter=0;
			
			if(abs(round_val - curr_adc) > 1)
			{
				curr_adc = round_val;
			}
			
			long double ocr = OCR_MIN + ((long double)curr_adc * (OCR_MAX - OCR_MIN)/1024);
			
			/*sprintf(uart_s, "ADC = %8lu, OCR = %f, rounded = %d\r\n", curr_adc, ocr, (int)round(ocr));
			uart_send_string((unsigned char*) uart_s);*/
			
			OCR1A = (int)round(ocr);
			
			//_delay_ms(100);
			sei();
		}
	}
}

but in proteus the ADC ports wont get enabled

Who gives a shit what happens in the simulator? What does the real hardware do? That is the ONLY thing that is important.

im sorry i didnt test it on real hardware ! before testing i wanted to test it on Proteus !!

Well if you need results/answers test it on a proto-board in real world and then go for the stand alone. No body would go dive straight into standalone.

anishkgt: Well if you need results/answers test it on a proto-board in real world and then go for the stand alone. No body would go dive straight into standalone.

I find this a little confusing.

It would be easy and useful and common to build a stand-alone prototype on a breadboard.

I agree that it would be unwise to design a PCB and fabricate a final product without proving the idea first (both the hardware and the software).

...R

Bread board and some call it protoboard. Results and answers, i meant, to accomplish what you have to its easier to get all done on a bread board than solder it on a etched pcb and then troubleshoot.