I am working with ATmega32-A micro controlleran ATmega32-A microcontroller.Using Using USART communication, I am displaying data on monitor.I and am using switch case to select different commands. In one of the commandcommands I have written the following code like:
case(DATA):
init_io();
statusreg = AD7798_8(0x40, 0xFF);
printf("status register %02x\r\n", statusreg);
if (statusreg != 0x80)
printf("unexpected power on status %02x\r\n", statusreg);
while(1){
while ((statusreg & 0x80) != 0); // wait till ADC is ready
adc = AD7798_16(0x58, 0xFFFF); // read register
printf("ADC value is %04x\r\n", adc);
}
Command=0;
break;
butBut the above code is printing the ADC value infinite times. I have changed the while loop like thisto the following
while(1){
while ((statusreg & 0x80) != 0); // wait till ADC is ready
adc = AD7798_16(0x58, 0xFFFF); // read register
printf("ADC value is %04x\r\n", adc);
}
After that it is printing only once, but it isdoes not accepting anymoreaccept any more commands. It got stucked there. I have to re-build if I want to enter any other command. anyAny help appreciated.