when i burnt the example hex file the hardware is working. but when the code i copied and compiled using keil uVision2 and converted to hex its not working what is the problem
actually i have it's working now..the problem was in the for loop
#include<reg52.h> void main() { int i; while (1) { for (i =0;i < 32000; i++) { P1_0 = 0; } for (i =0;i < 32000; i++) { P1_0 = 1; } } }
when i change the no. from 32000 to some another arbitrary then it's not working please tell me the reason......and another thing is when i program the same code for port0 it's not working......for port 1 and 2 the light is dimmer...i dont want that
What other "arbitrary" value? Note that 32000 is close to the limit for a signed integer.
Next thing - repeating the port output 32000 times isn't the way to create a delay. You really should separate the delay functionality from turning on or off the port pins. Your code would greatly change blink frequency if you add some extra lines of code inside the for loops. Having a delay function giving 100ms delay would mean that extra code together with the "port on" or "port off" would make an extremely small change in blink frequency.
please show me using some code.. and please explain me about port0