Mithun_K_Das
Advanced Member level 3
- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 26
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,252
Atmega8 problem in hardware. It works fine in simulation but if ADC is used it become hang in hardware. I don't understand why this is happening.
here is the code I used:
But if I remove the line where ADC is mentioned it works as usual with LCD. But whenever I add the line again, it become hang. Why?????????????
here is the code I used:
Code:
// LCD module connections
sbit LCD_RS at PORTB0_bit;
sbit LCD_EN at PORTB1_bit;
sbit LCD_D4 at PORTB2_bit;
sbit LCD_D5 at PORTB3_bit;
sbit LCD_D6 at PORTB4_bit;
sbit LCD_D7 at PORTB5_bit;
sbit LCD_RS_Direction at DDB0_bit;
sbit LCD_EN_Direction at DDB1_bit;
sbit LCD_D4_Direction at DDB2_bit;
sbit LCD_D5_Direction at DDB3_bit;
sbit LCD_D6_Direction at DDB4_bit;
sbit LCD_D7_Direction at DDB5_bit;
// End LCD module connections
unsigned char ch;
long tlong,sample,position,row,sign;
unsigned int adc_rd0, adc_rd1;
void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
DDRC = 0b11111110;
while(1)
{
adc_rd0 = ADC_Read(0);
adc_rd1 = ADC_Read(1);
Lcd_Out(2,1,"Atmega8 ");
Delay_ms(50);
}// while
} // void
But if I remove the line where ADC is mentioned it works as usual with LCD. But whenever I add the line again, it become hang. Why?????????????