Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

URGENT HELP!! Why my 8051 wont program!

Status
Not open for further replies.

AceOfHearts

New Member
Hi,

My very first few hex files worked (some of them more complex), for some reason the later hex files dont work once they are on the microcontroller (8051).

Its getting quite frustrating now, I have written these programs (assembly) which work when simulated, but when downloaded as hex, they dont work. However, my very first programs still work when downloaded!!!

What is the matter? I cant seem to be finding what I did differently at the beginning...

In need of urgent help. Any help appreciated.
 
I think the reason is that you have a bug in one or more of your programs. Let's start with a list of your assets. Which variant of the 8051 are you working with? Manufacturer and part number would be handy. What tools do you have at your disposal to debug your programs? Last, let's see the code that doesn't work with a detailed description of what does and does not work. That should keep you busy for half an afternoon.
 
I spoke to Crossware (www.crossware.com) who I brought the system from, I sent them a code (a simple LED blinking code), the guy tried it on his 8051 and it worked.

He forwarded to me some of the files, I examined his hex file with my one (they should be indentical as we both built the same file), and surprisingly, they were different!

His hex file was much shorter (about only 3 lines) whereas my one was several more lines long. I downloaded his hex file onto my 8051 chip, and it worked!! When I tried my hex file, it did not work...

Could it be the operating system I am using? I am using Vista. I have also tried XP but found the same problem. If so, why did it work at the beginning?!

Strange!
 
I think it is more likely that his version of the compiler and your version of the compiler have different settings. I'm thinking about things like memory models, or debug options, or optimizations. If you have the patience you can disassemble the code that works, then disassemble the code that does not and look for differences. It's a great way to learn assembly language.
 
Thanks Papabravo for your help. I really appreciate it.

You may be right when you say it is someting to do with settings. I had a look at his MAP file and my MAP file, there are some interesting differences.

First of all here is the HEX file we both compiled (simply blinking LEDs on P1):

; 8051 Initial Assembler Source File
public START
program segment code
rseg program
START ; startup code jumps to label START
; TODO: Add your assembler source code here

ORG 0

HERE: MOV A, #255
MOV P1, A

ACALL DELAY

CLR A
MOV P1, A

ACALL DELAY

SJMP HERE

DELAY: MOV R5, #7
HERE1: MOV R4, #255
HERE2: MOV R3, #255
HERE3: DJNZ R3, HERE3
DJNZ R4, HERE2
DJNZ R5, HERE1
RET

END




Here is his MAP file:

**broken link removed**


And here is my MAP file:

**broken link removed**


The "demo" bit is probably because my one is a demo version of Crossware Compiler and his one is not (though I paid good money for this 'demo' compiler).

Now, I know from reading the Getting Started Manual that the difference between the demo version and the full version is that in the demo version you can program up to 4K bytes, even if you have an 8K Bytes 8051.

Looking at the MAP file, one of the striking difference is that my program starts at memory location 4K instead of location 0 like his one does. and you cannot program beyond 4K...

The problem is, I am not sure what I can do to cure this problem.

I am looking at this window, which I think has got the correct setting in it for the 'Target Memory Location':

**broken link removed**

Right, if it has not become apparent already, I am a complete beginner in the microcontroller field.

If you can deduce something from the information I provided here Papabravo, or anyone else, your help is most appreciated.

peace.
 
It is the case that when the processor exits from the RESET state at power on it wants to fetch the first instruction from location 0x0000. This is where you want your code or at least a link to your code.

Many programmers allow you to load a hex file in and move it around by adding a constant offset. The problem with this is that the addresses inside may not get fixed up.

Unfortuneately there are many tabs which might have settings that will affect the results. You can however tell if the results are correct by looking at the hex file. The format is straight forward, and you can look at a .hex file with a text editor.

Each record begins with a colon(":") and ends with a newline (0x0A)
In between are hexidecimal digits that describe the data to be loaded into code memory.

First two digits are the number of data bytes in a record. This will typically be a hexidecimal 10, standing for 16 data bytes. Other values are of course possible.

The next four digits will be the sixteen bit code address

The next two will be the record type 00 for data records, 01 for an end record

Followed by the data bytes

Ending up with a checksum byte

What you want is a hex file whose first record looks something like

:10000000........

That would decode as sixteen byte data record located at address zero

Good Luck
Wish I was there
 
Yuck, Vista!
 
Hero999 said:
Yuck, Vista!
Man, that was some hairball that just came up. Maybe try professional grooming.
 
Thanks Papabravo.

Problem is still there...

What Operating System do you guys use (ie. Windows 2000, ME, XP, Vista etc.)?
 
Here is what works for me for 8051 programming development.

Editplus text editor with 8051.stx syntax file installed
I compile & simulate using Pinnacle IDE.(free up to 2k)
Pinnacle has its own editor but compared to editplus it is a bit lame.
For programming I use an old expro-60.
When programming target MCU I always use 2 devices so if it does not work I can go back 1 step without re-programming.

A handy hint is: don't work on the same file from start to finish, rename a backup file using increment or date/time each time significant editing has occured, this way you can go back & analyse when things don't work. This was especially helpful when I was making my dual ignition controller. It took about a week to write the program but months to get all(?) the bugs out.

Remember to document your code well, when I look back at my own code I often have no idea why I did it that way.

An OS should not have an affect on output files unless the program has issues with a partilular OS.
For me I use win98 because it is simpler than later win os's. but it depends on what else you do with your pc.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top