peg wrote:I have been pounding my head against a wall for a long time trying to work out why I couldn't get into a blank QG part
Hi Rob,
a) Manually remove power.
b) Manually hold BKGD pin low.
c) Restore power while still holding BKGD pin low.
d) Release BKGN pin.
f) Let BMD tool handle the rest.
Hi Peg,
You are right about power sources. I was using “USB power” (VB), which originated from the P&E USB BDM part of the DEMO board. Only this power source can be controlled by the PC software and P&E hardware.
Yes, I am quite sure that CW5.1 S08 Special Edition does turn off/on this power source when necessary. However, details of point (4) in my reply #7 were not quite correct. Here is my updated observation:
(a) RESET pin is never used.
(b) Normally, only BKGD pin is used to communicate with the chip and VB power is always on.
(c) When BKGD pin fails to communicate with the chip, CW drives BKGD low and turns the VB power off. (The green “USB” LED will stay on. The amber “OUT USB PWR” LED will turn off. The green “VDD” LED will also turn off.)
(d) After a delay of ~400msec, VB power is turned back on, but BKGD stays low for another ~36msec.
(e) BKGD is high and after another delay of ~5msec it is used to communicate with the chip again.
Peg,
I received the DEMO9RS08KA2. It is made by SofTec Microsystems. The schematic is complete and include the details of the USB BDM interface. If you want, I can send you via private e-mail, but I think you can get it directly too.
They use a MC9JB16FA chip to implement the USB BDM. They can turn off the power to the RS08KA2 chip, and they can change the voltage level of the RESET pin from 3.3V to 12V. (Like I said, they did all these using FET, not relays.)
Regards
OldManThis issue, as you already know, happens with new parts and in some cases with parts, especially when you are not using the reset line to control the MCU reset with a Multilink or any other tool or communication used; also, it has a "logic" explanation to say it in a way.
Starting with the parts that have never been programmed and keeping in mind that the programmer can't reset the MCU, when the MCU detects a reset it goes and take the contents of address 0xFFFE (reset vector), which in your case is 0xFFFF (blank state). Then the program counter goes to address 0xFFFF and takes the contents of this address as the first instruction, in this case again, 0xFF which is a STX ,X instruction. After this, the MCU keeps executing code from the area where the registers are located, and some of these registers are the contents of the ports and this can lead to random execution. What can happen here is "random" because you don't know the contents of all the registers and the data that is in RAM and it can go from an Invalid Operation Code to change the contents of a register and so on. Since the BKGD pin is multiplexed with a PTA pin, it might be possible that you are disabling the BKGD pin and that is why you can't go to background mode anymore. When the programmer can control the reset line, it can send a low state to the reset line and ensure that the BKGD pin is low when the reset goes high; by doing this the MCU will always go to an active BDM mode. In your case you don't have control in the reset line and I think that is why you can't execute a Background command and force the MCU into active BDM mode. When you already have a programmed part this is no problem because you know that the code executed by the MCU won't be random.
The watchdog case might be very similar. You need to execute a background command to enter to background mode but this is not done immediately after reset; it takes some time and depending on the communication it might be that the watchdog is causing a reset before the background mode goes active by the execution of a background command. In many cases, the BDM communication starts with a SYNC command, but this is not directly a BDM command meaning that this is a "handshake" between the host and the device to start the communication at the proper rate. Since the background mode is not enabled when this SYNC starts, it takes a little more than 128 cycles of the internal reference divided by 64 plus the time needed to start this SYNC. This might lead to the device to reset before executing a BDM command and you will have to start over again.
About your question regarding the BDFR bit, you have to remember that this bit has to be written using a background command; we go back to the same explanation, if the background mode never goes active, it is not possible to use this bit. Any attempt to write it from user's code will be ignored.
Normally when you don't have anything plugged to the MCU it works fine and you are able to program it (this is why it usually works with some Demo boards and then you are not able to do the same on your HW). Other option is trying to ensure that the BKGD pin is low at the rising edge of reset; if you are using a multilink normally it works having the multilink enabled and connected to the board when the power source is enabled (meaning that the multilink will be driving the BKGD pin low when the MCU is powered-up and this will go to active background mode).
However, the must secure way is to already have the part programmed when you put it in your board, knowing that this is very complicated when using surface mount parts (like SOIC packages). In the case of some distributors, they can sell you parts that come with some code from the factory, so this can help you to fix this issue.
I hope that this information clarifies the problem. Please feel free to contact us if you have further questions. Should you need to contact us with regard to this message, please see the notes below.
Best Regards,
Rafael
So it seems I was right in the beginning, it is just difficult.
Regards
Peg
Hi,
I am a newby and only have a DEMO9S08QG8 kit, so my knowledge is very limited. But here is my take.
(1) According to the QG8/QG4 datasheet Section 3.4, the PTA4/ACMPO/BKGD/MS pin acts as MS during POR. If the BDM tool holds this pin low while the QG8/QG4 chip powers up, the chip will enter active background mode. Thus the reset vector at 0xFFFE is ignored and should not cause any problem.
(2) The DEMO board comes with a built-in USB BDM from P&E. It is capable of controlling the power of the QG8 chip. It does not have any “relay”, but there may be a transistor or FET to do so. I do not have the schematic of this part of the DEMO board.
(3) CW 5.1 special edition that came with the DEMO board does use the power control capability of the P&E DBM described in (2) above. However, it does not use the procedure as described in (1) above.
(4) My observations are described below.
a) The Reset pin (pin 4 of the BDM connector) is never used.
b) Normally, Pwr (pin 6 of the BDM connector) is always on. Only BKGD (pin 1 of BDM connector) is used for communication between CW debugger and the QG8 chip.
c) If this communication fails, CW will turn off Pwr for ~440msec but BKGD remains high.
d) After Pwr is back on, BKGD stays high for another ~5.4msec.
e) After that, CW drives BKGD to low for ~10.8msec.
f) Hopefully, communication is re-established after this.
(5) My opinion is: CW debugger should have driven BKGD low when it turns the QG8 Pwr back on. This way, the chip will always power-up to active background mode irrespective of the contents of the Flash.
(6) My worry is: if the code intentionally or unintentionally disabled the BKGD pin or the ICSLCLK ***shortly*** after POR, the current CW debugger will never be able to force the chip to active background mode.