Okada
Banned
I am using ATMega8A to read ADC channel 0 and the code is working in Proteus but not on hardware (EasyAVR v7).
Here is the code. mikroC PRO AVR project and Proteus files attached.
Images show circuit, project settings and fuses.
I tested LED blinking an all port pins and they work fine.
Here is the code. mikroC PRO AVR project and Proteus files attached.
Images show circuit, project settings and fuses.
I tested LED blinking an all port pins and they work fine.
Code:
unsigned int adc_rd;
void main() {
DDRB = 0xFF; // set PORTB as output
DDRC = 0x3E; // set PORTC.0 as input for ADC
DDRD = 0xFF; // set PORTD as output
PORTB = 0x00;
PORTC = 0x00;
PORTD = 0x00;
REFS0_bit = 1; // use AVCC as VRef
while(1) {
adc_rd = ADC_Read(0); // get ADC value from 0th channel
PORTB = adc_rd; // display adc_rd[7..0]
PORTD = (adc_rd >> 8); // display adc_rd[9..8]
Delay_ms(300);
}
}