Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com 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

Status
Not open for further replies.

deeplearns

Member level 4
Joined
May 19, 2011
Messages
75
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,939
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 ...

#include<reg51.h>
void delay(unsigned int);
void main()
{
while(1)
{
P1=0x55;
delay(500);
P1=0xAA;
delay(500);
}
}
void delay(unsigned int time)
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);

}
 

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.
P1=0x00;
 
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 keil.com 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 ..so their should not be any problem with the memory limitation .. i suppose something else is wrong .


:100023007590557FF47E011200037590AA7FF47ECC
:060033000112000380EA47
:10000300E4FDFCC3ED9FEC9E5015E4FBFA0BBB0033
:0F001300010ABA04F8BBFBF50DBD00010C80E437
:0100220022BB
:03000000020039C2
:0C003900787FE4F6D8FD758107020023F3
:00000001FF
 

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 .
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top