I'm working with an 80C51 derivative, the P89C668HFA. At the moment, I'm trying to get some very basic functionality out of it- I just want to 1) disable ALE toggling and 2) get the I/O ports to toggle. I wrote a little bit of code to accomplish this:
MOV 08EH,#003H ; set lowest bit of AUXR low to disable ALE toggling
START:
MOV 080H,#000H ; Port 0
MOV 090H,#000H ; Port 1
MOV 0A0H,#000H ; Port 2
MOV 0B0H,#000H ; Port 3
MOV 080H,#0FFH
MOV 090H,#0FFH
MOV 0A0H,#0FFH
MOV 0B0H,#0FFH
SJMP START
END
The output of my assembler matches the hand-crafted binary that I started with. When I take the device out of reset, the ALE pin is still toggling, but not PSEN#, and the I/O port pins are all high. Given that information, and the fact that I am able to successfully program the device and verify that the program is correct, I believe that the device is working correctly, but it seems that the code is not being executed correctly (if at all).
I'd appreciate any thoughts on the topic, threads I could pull on, etc. Thanks.
Best Answer
Maybe you are running in a problem with the startup behavior of this chip.
In the data sheet on page 64 the Power-On Reset Code Execution is described. If you don't do anything to the special Status Byte the processor will start (by factory default) the internal boot ROM and not the application you have programmed.
It is suggested to program the status byte to 0x00, so that the code execution starts at address 0x0000. This is where your program is probably being put without any special treatment.
There is a section on how to erase and program the status byte via a record in the Intel-Hex-File on page 67: