Close or Esc Key

Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

ADC interface with atmega32 with two sensors

3 posts / 0 new
Last post
s.manisrinivas
s.manisrinivas's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 16/09/2015 - 12:05
ADC interface with atmega32 with two sensors

HI friends ,

  I need help from you that, I am using ATmega32 avr development board for ADC multiple channels  and i am using two POT sensors.What is my doubt is  I want a small delay after two channel conversions,say delay is 2 sec (for example).After every delay conversions have to display.

I tried but i cannot make delay,for i used timer buts its vain.so, please help me guys

 

here is my code.

#include<avr/io.h>
#define LED PD4 
 
int main()
{
uint8_t timerOverflowCount=0;
DDRD=0xff;         //configure PORTD as output
TCNT0=0x00;
TCCR0 = (1<<CS00) | (1<<CS02);
 
while(1)
{
while ((TIFR & 0x01) == 0); 
 TCNT0 = 0x00;
 TIFR=0x01; //clear timer1 overflow flag              
timerOverflowCount++;
if (timerOverflowCount>=6)
{
PORTD ^= (0x01 << LED);
timerOverflowCount=0;
}
}
}
 
 
 
 
GANEEV SINGH
GANEEV SINGH's picture
Offline
Last seen: 1 week 4 days ago
Joined: 22/07/2013 - 16:08
Hi thereCould you please

Hi there

Could you please share what output are you expecting from the above code.

According to me the LED should remain ON continuously without blinking with any specific delay.

Ashutosh Bhatt
Ashutosh Bhatt's picture
Offline
Last seen: 2 days 5 hours ago
Joined: 21/12/2010 - 15:59
if you are using AVR studio

if you are using AVR studio then in AVR studio you get built in delay function

_delay_ms() or _delay_us()