ISP problems in P89V51RD2

Started by Nilesh, February 19, 2005, 03:41:19 AM

Previous topic - Next topic

Nilesh

I am trying to switch 89v51 in ISP mode ,I have tried every thing ,it doesnt works
My Flash magic shows connected at 57600 baud rate  with 12 Mhz
but still It does not read device signature and flash memory.
it asks to connect at different baud rate and reset the device into isp mode


Andy Ayre

Have you tried lowering the baud rate? 57600 is pretty high for 12MHz...

Embedded Systems Academy, Inc.
support at esacademy dot com

Nilesh

If not at 57600 then at what Baud rate u think is good with 12mHZ

erikm

If not at 57600 then at what Baud rate u think is good with 12mHZ

A very low one.  You have made the common mistake of using a "processor crystal" (12MHz) instead of a "UART crystal" (11.0592MHz)

the keil baudrate calculator

http://www.keil.com/c51/baudrate.asp

wil show you the amount of error at various baudrates and anything above 1% MAY give trouble, sometimes - but rarely - up to 5% will work.


Erik

Jan Waclawek

This should not be the case, as using Timer2 for baudrate generator gives a rather negligible error of 0.16% with 57600bps at 12MHz.

Of course, you can still use 9600bps (with the same error).

I would suspect an incorrect level translator (MAX232 or similar) or wiring problem.

Jan Waclawek

erikm

This should not be the case, as using Timer2 for baudrate generator gives a rather negligible error of 0.16% with 57600bps at 12MHz

It does not have any effect what YOU (your code) uses, what has effect is what the bootloader code uses.  It would be interesting if a Philiops guy could answer that.  Andy, any contacts?

Erik

Andy Ayre

Autobauding measures the baud rate and uses an approximate value for the timer 2 reload rather than precisely calculating it. Therefore the errors are larger. The error depends on the speed of the device and the exact code used to perform the autobauding. Really the only way to find out if a specific baud rate works is to try it and see. Generally the slower the baud rate the better the chance it will work.

Embedded Systems Academy, Inc.
support at esacademy dot com

Jan Waclawek

There is not a single reason why the bootloader would not use the best available method for baudrate generation - Timer2.

As the autobaud routine measures only a single negative pulse to determine the baudrate, with assymetric shift in up and down going edges (which is not rare at RS232, especially at longer cables and higher data rates) it can easily end up with an improper reload value for Timer2. Indeed, if in the given case the reload value differs by 1 from 13, the error increases to 7-8.5%, which is just good to produce intermittently working connection - exactly as described by the original poster.

As Andrew pointed out, a small deviation in the determined reload value has much less detrimental effect at lower bitrates.

Anyhow, any serial communication is usually more reliable at lower speeds, regardless of the exact cause.

Jan Waclawek

PS. Apart from theory, I just tried the given setup (57600bps, 12MHz) and the bootloader obviously invariably sets the reload value to 14, which gives 53571bps, 7% error. Pretty unusable; sending "U" (55h) echoes randomly 75h and 35h...  
38400bps works quite fine...



Post Edited (02-23-05 03:34)

erikm

anyhow,

This should be directed at Philips, not Andy.

The Bootloader code is all Philips.

Erik

Jan Waclawek

PS2: More experiments
Experimenting I found out that the problem is associated with chip being set to 12-clock mode. In this mode, the Timer2 clock is fosc/2 rather than fosc; hence it is impossible to set the proper reload value for 57600bps @ 12MHz (which would be 6.5). Setting the chip to 6-clock mode, it is possible to operate the UART at 57600bps @ 12MHz; but due to inherent uncertainty in determining the baudrate with the autobaud routine it sometimes works and sometimes not (experiments gave me a 1:1 ratio).

Nevertheless, the chip is set at 12-clock from the factory, so it is impossible to change the double-clock bit via ISP at 57600bps @ 12MHz.

The Philips datasheet is far from being crystal clear as the Timer2 operation as baudrate generator - the picture contains a ":2 box" between oscillator pin and timer counter; while the following text states several times, that the input frequency is fosc - and it is mentioned nowhere that this is clock-doubling dependent.

Although the operation of chip and unclear datasheet is not Andrew's problem, the resulting unclarity as per bootloader operation is (at least he needs answer questions like these).

Jan Waclawek

Jan Waclawek

A summary of what baudrate shall/can be used for P89V51RD2 bootloader is at http://www.efton.sk/t0t1/autobaud_error.htm

I hope this will help Andrew and others in determining the proper baudrate.

Jan Waclawek

Jan Waclawek

Dear Andrew,

while playing with the P89V51RD2's bootloader, I tried a couple of things with the FlashMagic and noticed this and that - maybe of some help to you.

I am using v2.07 (but I read the release notes and found nothing in the newer versions that would be relevant to the following).

1.  The original poster was confused by the behaviour of FlashMagic, when the chip baudrates to an improper value. With 57600bps  @ 12MHz,  it almost invariably falls into the -5% region, where it echoes back a mixture of "u"-s (75h-s), "5"-s (35h-s) and 15h-s. When this happens while FlashMagic  displays the "Reset Device" window at FlashMagic startup, it displays a window saying (a rather long text, just the beginning here) "Unable to read the security bits..." If I click Retry, the situation repeats. But if I click Cancel, then select (with the same baudrate)  e.g. Read device signature, then the behaciour changes - after the Reset Device window (and improper autobauding) a Unable to connect at specified baudrate window comes.
This is rather confusing.

2. FlashMagic could possibly test the presence of the chip permanently (maybe as an option, with a possibility to enable/disable it).  Helps with experimenting with baudrates and maybe also in production.

3. There is a very nice feature built into FlashMagic - the "HighSpeed Communication" (in Advanced options).  This is a real way to go - autobauding to a safe baudrate, then by direct setting of the reload value switch to the possible maximum. But - oops - disabled for P89V51RD2...
OK, some hacking needed :-)
Having a look into the P89C51RD2 datasheet I see, that the "manual baudrate" works absolutely the same way. Thankfully, FlashMagic is not pecky with the non-matching signature (although... a warning (possibly switchable off) would be perhaps good for safety).
So I autobaud to some 2400bps at the P89V51RD2 setting, then switch to P89C51RD2, set the Xtal value (12MHz) and enable the HighSpeed Communication. First surprise - according to the description in the manual I would expect that the list of maximum baudrates would now contain only the "good" baudrates - but it remains a full list. Never mind, I select 115200bps for maximum (and set properly for 12-clock operation). Starting some communication, it sets 19200bps (displays it for a while at the top bar of the program window; speed confirmed by testing using a terminal emulator)...
Why???
At 12MHz, using a reload value of -10 the baudrate is 38400 bps with error of -2.34%. OK, this might be too high, but then reload value of -13 gives 28800 bps with error of 0.16%! More, the best error for 19200 bps  is at reload value of -20, yielding the same -2.34% as with 38400 bps...
I think, the method of calculation the maximum baudrate should be reconsidered...

4. While playing as described in previous section, FlashMagic in the P89C51RD2 mode sets the P89V51RD2 invariably into SoftICE mode. For P89V51RD2 this is done using the 02 intelhex command. A quick look into the P89C51RD2-s datasheet (dated 2002 Jul 18) - there is NO 02 intelhex command for it! Why does Flash Magic use it then?

5. A minor nuissance: I noticed, that when I select e.g. Read Device Signature (but also some other operations), the window which opens (containing the signature), cannot be closed from the keyboard (no focus on the Close button, ENTER nor ESC does not work) except Alt-F4. Funnily, if I then switch to another window and back (pressing Alt-Tab twice), the focus appears on the Close and both ENTER and SPACE works (but still not ESC).



Jan Waclawek

Andy Ayre

Thanks for the feedback. We will look into your comments and identify ways to improve Flash Magic. However I do have one response.

4. The protocol for the C51RD2 and V51RD2 are not the same. The 02 hex record was used in the second generation Rx2 family to set the oscillator frequency. I think this was removed for the third generation. Unfortunately this record places a V51RD2 into SoftICE mode.

Embedded Systems Academy, Inc.
support at esacademy dot com

Beatriz Trist

Hi

I want to program via parallel but I proved it and It didn

Beatriz Trist

Hi

I want to program via parallel but I proved it and It didn