| ??? 10/13/03 04:57 Read: times |
#56571 - Un expected stalling of software |
Hi Guys,
got some problem. I just finished a program that blinks an LED (24 V) and the blinking speed is controlled by the value at Port 2. The program is: // Using Philips 89C51RD2HBP chip running in 12 clock mode at 12 MHz.
#include<reg51.h>
int DELAY;
void delay();
void main(void)
{
P1 = 0; // Connected to LEDs
P2 = 0xff; // Input Control Port
TCON = 0;
TMOD = 0x01; // Timer 0 in 16-bit Mode. Not using Timer 1
IE = 0x82; // Enabling Timer 0 Interrupt only
TH0 = 0x3c; // Delay for a 50 milli Sec
TL0 = 0xaf;
TR0 = 1; // Enable Timer 0 Interrupt
while(1)
delay();
}
void delay()
{
int i; // Wait for some time doing nothing.
for(i=0;i<32700;i++); // If I dont use this function, the
} // program is hanging.
void T0_ISR (void) interrupt 1
{
static int counter;
static int val;
if(counter == (255 - P2)) // Inverting P2 so that I
// Ground only required pins.
{
if(val == 0)
{
P1 = 0xff; // Switch on the LEDs
val = 1;
}
else
{
P1 = 0; // Switch off the LEDs
val = 0;
}
counter = 0;
}
else
counter++;
}
Now, Coming to the problem. If I switch on the board after I set the desired value at P2, the program runs perfectly well. But if I try to change the value at P2 in between.....The program Freezes..!! Would someone mind explining the point that Im missing? Cheers, Harsha. PS: slightly confused about the points this question earns.. Isnt it +100? :)) |
| Topic | Author | Date |
| Un expected stalling of software | 01/01/70 00:00 | |
| RE: Un expected stalling of software | 01/01/70 00:00 | |
| RE: Un expected stalling of software | 01/01/70 00:00 | |
| RE: harsha's points | 01/01/70 00:00 | |
| RE: harsha's points | 01/01/70 00:00 | |
RE: harsha's points | 01/01/70 00:00 |



