Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Facing problem with keil compile c code

Not open for further replies.


Member level 4
May 19, 2011
Reaction score
Trophy points
Activity points
Hi I am trying to run a basic led blink program using 89s51 microcontroller .
I compiled the program in kiel (c) and then when i burn it into the micr controller and ran the ckt .. the leds just stay on .
I have learnt that when program compiled in Kiel c compiler it starts at location 0x4000 .
could that be the problem .
i tried the simple led blink several time ...and when i simulate it on Proteus it works fine .???

Please Help .

post your program ,that may easy to help others you .

I have compiled the code in Keil and simulated it in Proteus works fine ....but when tested doesnt do any thing ...

void delay(unsigned int);
void main()
void delay(unsigned int time)
unsigned int i,j;


Is your programmer working fine ?

Your code seems to be correct. check your hardware connections. Pin 40 and 31 should be connected to Vcc. 20 to Gnd.Crystal between 18 and 19. Pin 9 with Reset circuit.

---------- Post added at 16:14 ---------- Previous post was at 16:05 ----------

make your P1 as an Output before writting to it.
add this line just after the main function.
Yes i have double checked the connections and wil try the P1=0x00; method too .as do not have the serial programmer cable right now ..

Thanks for the replie i will try it ....
Could you tell if the following is correct

Program code starts at address 0x4000
All C code compiled and linked using the Keil tools will begin at address 0x4000 in code memory. Such code may not be programmed into devices with less than 16Kbytes of Read-Only Memory. Code written in assembly may circumvent this limitation by using the "origin" keyword to set the start to address 0x0000. No such work-around exists for C programs, though. However, the integrated debugger in the evaluation software may still be used for testing code. Once tested, the code may be compiled by the full version of the Keil software, or by another compiler that supports the C extensions used by Keil.

I found this through this link

Free 8051 Microcontroller projects - 8051 C Course

I dont agree that "we need a device having atleast 16k On Chip Flash. just download the keil software form and complile your code it will run on 89s52(having 8k On Chip Flash). I have made many projects on 89s52 using keil. They all work fine.

I checked the hex code and it shows that the code starts at 2300 their should not be any problem with the memory limitation .. i suppose something else is wrong .


check using multimeter or cro if the port 1 toggles properly or not... also put a 10K ohms pull up resistor to all the port pins..... if it does not work then change the controller.....

Make sure that your port pins are working properly. Sometimes its possible that the ports get damaged.

It seems to be workiib now , it was the microcontroller which was causing problem ..i used another one and it worked ..thanks a lot to all .

Not open for further replies.

Part and Inventory Search

Welcome to