Monitor/Normal operation in same circuit? (JK8)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Monitor/Normal operation in same circuit? (JK8)

6,539件の閲覧回数
AveryZ
Contributor I
Hi!
 
Specifically for the JK8, but also in general for the entire HC08 family, is it possible to have a single circuit that is capable of both monitor and normal modes? I vaguely recall seeing a PDF or ref design 6 months ago that addressed this but I can't find it anymore or it never existed in the first place!
 
Is this possible? How would it differentiate between when to go into Monitor and when to run normally?
 
Thanks,
Avery
ラベル(1)
0 件の賞賛
返信
19 返答(返信)

2,741件の閲覧回数
sungam
Contributor I
Hello,
 
I am so sorry, I should have tested the code I gave.
First, the adress to the subroutine was wrong it should of course be 0xfcbe and I also forgot to load H:X with the adress of the datablock.  Well.. I guess you recognized this when you took a closer look.
Anyway it did still not work properly, it left the adress FFFF at 0xF7  (resetvector) for some reason.
The problem must be that the program returns to the erased flash.
Since I have problem with copying the program to RAM in the C-environment, I tried another aproach, to copy the OP-code for "bra *" into ram, let the stackpointer point to the adress of that.
I have now tested it an it works well.
 
I am so sorry if I caused you extra work with the incorrect code, but this should work.
 
Here in the main.c file:
 
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
void Erase(void)
{
 asm{
    clr        CONFIG2    
    mov        #0x31,CONFIG1   //disable cop andLVI
    ldhx       #0xffff
    sthx       0x62            //this tells the rom-routine to erase entire flash
    mov        #24,0x60        //crystal speed 24Mhz
    ldhx       #0x20fe         //OP-code for bra * in RAM
    sthx       0x70
    lda         #0x70
   psha
   clra
   psha
   ldhx       #0x60
    jmp        0xfcbe          //jump to erase routine in ROM,
                               // OBS! not jsr !
 }                            
}                              
 
void main(void) {
 //EnableInterrupts; /* enable interrupts */
 /* include your code here */
 if(PTB_PTB0==0) Erase();//erase flash if PTBO is =0 (PTB0 is the monitor pin)
 for(;:smileywink: {
  __RESET_WATCHDOG(); /* feeds the dog */
 } /* loop forever */
 
}

Message Edited by sungam on 2007-03-0410:05 PM

0 件の賞賛
返信

2,741件の閲覧回数
AveryZ
Contributor I
Thanks again everyone for your replies, you are all awesome!
 
I am making progress on this but it is still not working correctly - I can erase the flash but am having trouble communicating with the processor in Monitor mode after a reset. my PTB0 is pulled high and has the single line serial link (same as when using high voltage entry monitor mode) and IRQ is tied to VDD, all as described in the data sheet. My crystal is 9.8304 and I have tried connections through P&E at 9600 baud for both ICS board w/ MCU and Custom Board. Neither is working. I am thinking that maybe something is not working with the Flash Erase since the only remaining non-verifiable entry condition is that the flash was correctly erased. I have tried using both the code posted in the entry right above this response andthe code pulled from the zip in the post before that, same result both times!
 
-Avery
0 件の賞賛
返信

2,741件の閲覧回数
peg
Senior Contributor IV
Hi Avery,
 
I guess what you need to do now is do a normal high voltage monitor entry so you can check whether the device is indeed blank. (Actually only the reset vector needs to be blank).
You would need to try the security code for whatever was in the device before and if that doesn't work try the code for blank as the problem may be that only the reset vector still has a value (like sungam has suggested)
 
0 件の賞賛
返信

2,741件の閲覧回数
AveryZ
Contributor I
Excellent Idea. The results are puzzling though:
 
FFF8 FF FF FF FF FF FF FF FF ........
 
This must mean that the flash erase was succesfull - and I am 100% sure that I have the proper signals, yet the device will simply not go to monitor mode!
 
-Avery
0 件の賞賛
返信

2,741件の閲覧回数
sungam
Contributor I
Hello Avery,
are you making any progress?
 
I just remembered, when I made my first mon08 programmer I sometimes had problems entering monitormode and that was related to the supplyvoltage. To have a POR the voltage has to go below 100mV. In my programmer, class1 voltage controlled by DTR, I added a transistor that recharged the supply voltage when DTR not active.
 
regards
 
Sungam
0 件の賞賛
返信

2,741件の閲覧回数
AveryZ
Contributor I
Hey Everyone,
 
Making some progress -> After reading all these posts again (especially the most recent), it became clear that my primary problem was that I could not communicate with the processor from my in-circuit board (through the PTB0 method). Turns out this had nothign to do with wiring, erasing, or anything like that; it was strictly an issue of resetting the MCU incorrectly. I would reset it by completeley unplugging the power and then plugging it back in; WRONG! Now i reset it by driving the RST pin to low for a little bit and then letting it go back to high - works like a charm. I can open up CW and communicate with the MCU without a problem, including reprogramming.
 
This is a 100% functional solution, the only issue is that the device does need to be completely reprogrammed in order to do anythign with it b/c I get a "ROM Is Secure" message. I am exstatic that this is now the height of my problems :smileyhappy: At least now I dont have to keep switching from programmer to circuit and so on....this is very awesome!
 
Thanks for all of your help!
-Avery
 

Message Edited by Avery Z on 2007-03-0803:27 AM

0 件の賞賛
返信

2,741件の閲覧回数
peg
Senior Contributor IV
Hi Avery,
 
Great that you got it working, but, have you checked the supply voltage on the device when you switch off the power? Perhaps it is staying above 100mV for a very long time.
Maybe you need a dummy resistive load or a power switch _between_ the power supply and the target device.
 
0 件の賞賛
返信

2,741件の閲覧回数
peg
Senior Contributor IV
Hi Avery,
 
Well now it really is weird, as you are pretty much confirming the low voltage entry conditions as they are a sub-set of the high voltage ones. Also the reset vector appears to be blank.
 
You are doing this from Codewarrior, Yes?
What if you go into expert programmer mode and then do a blank check module test?
 
0 件の賞賛
返信

2,741件の閲覧回数
AveryZ
Contributor I
Wow! Thank you all for your replies! It looks like ICP is exactly what I am looking for! I have a few questions:

1) Does the flash need to be erased before the call to MCU_init or could I accept a command from the pc over SCI (i.e "ERASE") and then call the erase routine.
2) Reprogramming -> Will i be able to use CodeWarrior to reprogram once I have it in forced monitor mode?
 
Thanks!
-Avery
0 件の賞賛
返信

2,741件の閲覧回数
peg
Senior Contributor IV
Hi Avery,
 
1. You could initiate the erase from anywhere. Programme execution moves to RAM, bulk erases the FLASH and loops in RAM waiting for reset.
 
2. Yes of course you can use CW. Once it is reset after above steps it is exactly the same as a new virgin device.
 
0 件の賞賛
返信

2,741件の閲覧回数
AveryZ
Contributor I
OK! Thanks Peg! I have  a pretty good handle on what's going on now, and I've read all the PDFs about rom resident routines for erasing the flash (and the post earlier up on this thread with actual assembly has been useful as well :smileyhappy: ) but I am having difficulty getting everything to work.  The two main issues are:

1) How to move a function into RAM (the erase function)
2) The setup of the ROM erase function for my specific processor (JK8) is explicitly listed in the datasheet but I am (embaressing) having trouble translating it directly for my application (simple erase all of flash for an "instance B" device)
 
Thanks!
Avery

Message Edited by Avery Z on 2007-03-0402:31 AM

0 件の賞賛
返信

2,741件の閲覧回数
peg
Senior Contributor IV
Hi Avery,
 
AN-HK-32 shows you how to move the code into RAM at label NEXTRAM:
The code that is moved should use short relative branches so the jumps still work after the code is moved!
As for the second question, I know the document you are probably referring to with this "instance b" stuff but perhaps you can tell me the AN number.
 
0 件の賞賛
返信

2,741件の閲覧回数
AveryZ
Contributor I
0 件の賞賛
返信

2,741件の閲覧回数
bigmac
Specialist III
Hello Avery,
 
Do you have the software file specifically associated with AN2874?  This shows how to set up the RAM buffer, and to identify the start of the buffer in C.  The sample code demonstrates a page erase, but a mass erase should be equally as simple.
 
Since the ERARNGE routine is located in ROM, it is only necessary to load the few bytes of data into the RAM buffer, identify the start of the buffer, and then call the routine (using inline assembly).
 
Regards,
Mac
 

Message Edited by bigmac on 2007-03-0403:55 PM

0 件の賞賛
返信

2,741件の閲覧回数
peg
Senior Contributor IV
Hi Avery,
 
Note that the AN-HK-32 is for GP which does not have ROM based routines.
That is why you have to do it manually from RAM.
You could do it this way with the JK8, but the JK8 has ROM based routines so you don't need to execute from RAM just load up some pre-defined RAM locations with some parameters then jump to the routine in ROM.
AN2874 takes this approach.
Perhaps this is leading to your confusion.
 
0 件の賞賛
返信

2,741件の閲覧回数
sungam
Contributor I

Hello,

You can use ISP with only the datapin used.

To do that the flash has to be erased for the device to enter monitormode (i think it is called forced monitormode). You will find a description of these in the databook <Rom-Resident Routines>, but I will give you an example for the 908JL8 processor. The small processors have built in flash erasing routines in ROM and the ones with more RAM haven't but you can copy the erasing program to RAM and then jump to RAM.  If the flash is erased the monitor uses the crystal oscillator so no external oscillator is needed. For the JL3 the baudrate will be crystal_MHz/9.8304*9600. Unfortunately there is no suitable standard baudrate for 32MHz crystal, but if you use 24MHz then you can use a baudrate of 23040.

Here's an example of erasing the JL8: I have an pullup on the monitorpin PTB0 and if it is = 0 at program start the flash is erased. Of course you can use any condition you like to erase the flash

void Erase(void)
{
 asm{
      clr        CONFIG2      mov #0x31,CONFIG1         ;disable cop andLVI
     ldhx      #0xffff
     sthx     0x62                 ;this tells the rom-routine to erase entire flash
      mov     #24,0x60        ;crystal speed 24Mhz

      jsr        0xfc06           ; jump to erase routine in ROM, of course after this it will return the the
  }                                     ;erased flash but that will not do any harm as you recycle the power
}                                      ;and the monitor will start

void main(void) {
   if(PTB_PTB0==0) Erase();//erase flash if PTBO is =0 (PTB0 is the monitor pin)
   MCU_init();

After flash is erased the mcu starts in monitormode without any other conditions required. It is using the same oscillator as in user mode so it means in this case that the only pin sacrified is PTB0 .

When you start the debugger, specify the baudrate to 23040 if you are using JL8 with 24MHz crystal .

Hope you find this information useful

Sungam

0 件の賞賛
返信

2,741件の閲覧回数
peg
Senior Contributor IV
Hi Avery,
 
AN-HK-32 is a good reference for the method proposed here by sungam.
I actually use a method based on this with the GP32 in a product.
This of course depends on whether you are looking to simply re-programme or debug.
 
0 件の賞賛
返信

2,741件の閲覧回数
peg
Senior Contributor IV
Hi Avery,
Of course this is possible.
First the clock has to be suitable for both. Then just look at the table that shows the conditions required for monitor mode entry. Then setup those i/o so that you can meet these or change a jumper (or something like that) to make at least one condition fail so it will come up in user mode. With some though you can still use the pins used for MON08 mode (a pulled up pushbutton for instance)
 
0 件の賞賛
返信

2,741件の閲覧回数
HonHo
Contributor I
Besides designing a special circuit with addtional componets, your problem could be solved by our inDART series debugger like inDART-One. It features with internal relay and makes use those unused pins of the MON08 interface. We call it Enhance MON08 interface.
 
In short, the mechanism is that inDART-One will control the MCU to enter the monitor mode, and then it will release the lines and relay those MCU signal for your target application. For better description, I suggest you to download our inDART-One user manual at:
 
In session 5.3.2, it describes this feature in detail and we have a diagram which guide you how to design and connect our inDART-One with this great feature.
 
I hope it helps.
0 件の賞賛
返信