Author Topic: P89V51RD2BN RAM address 3Bh altered  (Read 8174 times)

vanupied

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
P89V51RD2BN RAM address 3Bh altered
« on: June 13, 2005, 07:02:44 am »
I am evaluating this device for direct replacement of the Intel D87C51Fx in an older design. This design uses a backup battery that shall be replaced by the Philips device's flash.

Our software calculates a checksum over the internal RAM (excluding the first register bank and the stack area) before setting the PD (Power Down) flag. The same calculation is done immediately at start-up and the comparison of the two checksums allows reliable detection of RAM data loss.

Unfortunately this same program doesn't work with the P89V51RD2BN, since the internal RAM data at address 3Bh and 21h are altered somwhere between the two checksum calculations.

I figured that probably the Philips Bootcode (V4) uses some RAM when doing autobauding. Therefore I added some code to set the BSEL flag in the power down procedure right before setting PD. It seems that the device boots directly to user code (since FlashMagic is not able to connect), but the mentioned memory is still altered.

Does anybody have any explanation to what is happening? What are the first steps the device is doing after Reset?

Again: The same code works on an Intel D87C51FB1 without the memory beeing altered.

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2167
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #1 on: June 13, 2005, 12:03:40 pm »
From Philips: "RAM locations 20h and 21h are used for bit storage by the bootloader: 3 bits at 20h and one at 21h. RAM is then used starting at location 30h, with the stack changed to location 3Bh (SP = 3Ah). These contents will be altered during the attempt to autobaud. So, its easy to see that these locations will get altered during a "normal" power-up sequence before running user code."

I hope this helps.

Embedded Systems Academy, Inc.
support at esacademy dot com

vanupied

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #2 on: June 13, 2005, 12:28:11 pm »
Thanks a lot. Of course this information explains many things I was trying to figure out during hours. Thank you.

There is a 'normal' power-up mentioned. I thought that I could prevent the bootloader from getting active by setting the BSEL flag. How to explain that the bytes are still altered? The bootloader gets active in all cases? Is there no way to inhibit it?

Thank you again for your help.

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2167
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #3 on: June 13, 2005, 01:16:20 pm »
After power on, the bootloader is always started. If the autobaud procedure is not completed within the watchdog timeout period, then user code is executed. There is no way to avoid this happening.

Embedded Systems Academy, Inc.
support at esacademy dot com

vanupied

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #4 on: June 13, 2005, 01:35:14 pm »
Thank you for your answer. Although it's no good news, it will help me to live with it and to stop turning around trying to debug our soft where there is nothing to debug.

Jan Waclawek

  • Full Member
  • ***
  • Posts: 220
    • View Profile
    • EFTON homepage
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #5 on: June 14, 2005, 01:16:31 am »
If you don't need the bootloader(e.g. if you are using a parallel device programmer), you can possibly replace it with a short code thet uses no RAM and switches to the user FLASH immediately. Even if you need the bootloader, it can be possibly modified so that it won't use any RAM until successful autobaud.

Jan Waclawek

vanupied

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #6 on: June 14, 2005, 02:45:20 am »
A replacement bootloader sounds good to me. Is this open source? Is it possible to get it from Philips?

erikm

  • Guest
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #7 on: June 14, 2005, 05:57:21 am »
There is a common misconception that you can use the flash routines and expect your RAM to be the same afterwards.  The Flash routines are made with programming in mind and after programming a reset is always required.  

If you use the flash routines do a watchdog timeout afterwards.  

"finding out" which RAM etc is affected by the flash routines is futile since there is no guarantee that the next batch of chips will use the same.

Erik

Jan Waclawek

  • Full Member
  • ***
  • Posts: 220
    • View Profile
    • EFTON homepage
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #8 on: June 14, 2005, 08:16:04 am »
Erik, this is different from the P89C51Rx2's - there, if you program the status byte properly, after reset the user program starts to execute immediately, so you can rely on that RAM will remain unaltered from the pre-reset state (usable e.g. if you use the powerdown mode and battery-backup the RAM) (while, yes, if you use the IAP routines, or go to ISP in any way, it alters the RAM).
But in P89V51RD2, the bootloader starts involuntarily after reset, modifying the RAM, before it jumps into the user program start.

If the "next batch" is programmed by YOUR bootloader, it will be the same...
And Philips recommends using a particular bootloader downloadable from their site, so that will be consistent, too,  as long as they don't change or withdraw that bootloader.

Unfortunately, Philips did not publish the details of the FLASH programming. But one can consider the remarkable similarity of P89V51RD2 to a '51 clone of an another manufacturer, which did publish the necessary data...

Jan Waclawek



Post Edited (06-14-05 08:19)

erikm

  • Guest
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #9 on: June 14, 2005, 10:13:33 am »
But in P89V51RD2, the bootloader starts involuntarily after reset, modifying the RAM, before it jumps into the user program start.
And instead of the RAM being "random" a few bytes are "something" biiig deal.

Erik

Jan Waclawek

  • Full Member
  • ***
  • Posts: 220
    • View Profile
    • EFTON homepage
Re: P89V51RD2BN RAM address 3Bh altered
« Reply #10 on: June 14, 2005, 11:35:03 pm »
Reset != power-up

Jan Waclawek