I am writing a very simple application which allows one to change the temperature. The temperature is displayed using LEDS (BCD format)
I wrote the following code in Keil C51:
#include< REG51.h>
sbit select = P1^7;
sbit up = P1^0;
sbit down = P1^1;
int data room = 24;
void main()
{ int prog;
P2 &=0x00;
P1 |=0x83;
prog = 0;
while (1)
{
if(select == 1)
prog++;
if(prog == 1)
{
if(up == 1)
room++;
if(down == 1)
room--;
P2 = room;
}
}
}
I then complied this and obtained the Intel hex file which i then tried to simulate using the Edsim.
According to the C code the temp should change when prog=1 and when either up(p1.0) or down(p1.1) is pressed, but in the simulation it only changes when both select(p1.7) and up/down is pressed!
Why is this happening?