MON08 Programmer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MON08 Programmer

4,789 Views
nw
Contributor I
First of all, I'm new to this whole microcontroller thing, so get ready for a lot of dumb questions asked in a short amount of time.

I built the monitor mode circuit from Application note 2317, and have used it to program a couple of GP32s to blink LEDs and the like. The problem is that I don't really know what i'm doing and the monitor mode circuit is integrated into the circuit that my micro controls. I was planning on building a PCB with the monitor mode circuit from AN2317 and just mounting a header on that board to use for ISP, but first i have a few questions.

1. How does someone typically add an ISP interface to a target circuit? Would i have to sacrafice the PTA0, IRQ, and other pins that are needed to bring the MCU into monitor mode? If not, how do people avoid things like short circuits, do they have a way of disconnecting the target device from the circuit it controls?

2. Should my programmer board provide power to the target, or does the target pwoer itself. If are powered by different power supplys, could that pose a problem with different ground potentials?

3. Should my programmer provide the 9.8304 MHz clock to the target? Also, how do you set an HC08 to run of it's internal clock, as my devices have a tendancy to quit working whenever i disconnect the programmer?

Basically I would like to know how people lay out the headers on thier programmers and how they handle things such as the signals on portc when the controller is starting up to bring it into monitor mode.


Sorry for the dumb questions and thanks for any help!
Labels (1)
0 Kudos
4 Replies

430 Views
nw
Contributor I
Thank you both for the help. For now, I think i will just avoid using the Mon08 pins for anything else for simplcity. I did have another question about clocks though. How do you set a chicp to run off of its internal clock by default? So far i have only been able to get anything working with and external oscillator. The specific chips are the kx8 and gp32.

Thanks again!
0 Kudos

430 Views
peg
Senior Contributor IV

Hi nw,

Not sure about the KX8 but with a GP32 its very difficult 'cause it ain't got one.

You either use a canned osc, a high freq xtal or a low freq xtal and the PLL.

BR Peg

Message Edited by peg on 04-11-200607:29 PM

0 Kudos

430 Views
sungam
Contributor I

Hello,

I am using ISP with only the datapin used.

To do that the flash has to be erased for the device to enter monitormode. There is application notes on how to do this, but I will give you an example for the 908JL3 processor (a good processor to start with).  The small processors have built in flash erasing programs in ROM and the ones with more RAM haven't but you can copy the erasing program to RAM and then jump to RAM. I think there is an application note for how  to to this on GP32 (AN1770). If the flash is erased the monitor uses the crystal oscillator so no external oscillator is needed. For the GP32 with its 32kHz crystal the baudrate on monitor pin will be 9600 baud.

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 JL3: 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 main(void) {
   if(PTB_PTB0==0) Erase();//erase flash if PTBO is =0 (PTB0 is the monitor pin)
   MCU_init();

listing of erase.c

//#include "JL3_REGS.h"
#define config1  0x001F    // System configuration register
#define config2  0x001E    //System configuration register

void Erase(void)
{
 asm{
      clr config2
      mov #0x31,config1         ;disable cop andLVI
      clrx
      lda      #0xff
      sta      0xfe09
      mov      #0b01000000,0x88  ;prepare for masserase
      mov      #0x18,$89        ;crystal speed 24Mhz=> 24dec.
      ldhx     #0xffff
      jsr      0xfc06           ; jump to erase routine in ROM
  }
}

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.

I have attached an simple programmer that can be used with any HC08 mcu(EAGLE files). The onboard sockets are for JL processors but you will only need the 3-pin ISP header: +5V, monitorpin and GND. The power can be switched by the DTR line, or manually - useful when you want to test your program and use the programmer as the powersource.

When you start the debugger, choose class 1 interface and specify the baudrate to 23040 if you are using JL3 with 24MHz crystal and if GP32 choose 9600.

Hope you find this information useful

Sungam

0 Kudos

430 Views
peg
Senior Contributor IV

Hi nw,

Firstly, with the questions you have asked here you will get a different answer from every person you ask!

Here are my answers:

1. Especially if your new and experimenting, its best to provide the whole 16 pin MON08 connector on your PCB. If you want to use a MON08 pin for something else, wire that something else to the odd numbered pin opposite. This way when you don't have the programmer plugged in you use a jumper shunt to bridge the adjacent pins (1 to 2, 3 to 4 etc). This also means not using the power and OSC pins in the MON08. which brings me to 2. The downside of this is you can't debug through the MON08 to that peripheral.

2. Probably not at your stage. The programmer supplying the power is handy on a production line and for automatically cycling the power but not necessary for you. When you connect the programmer you will tie the programmer ground to the CPU ground so you already have to allow for this.

3. If you can arrange for your board to run on an oscillator that works for the Monitor this is the easiest. If not, then your programmer must supply the OSC. Which specific HC08?

I have a product that has no MON08 specific pins or pullups whatsoever. As a number of signals go off the board anyway (to LCD's and option boards etc) I arranged it so all of the MON08 pins where used for these. That way I just have an adapter that plugs into 3 different sockets and adapts them into a standard MON08 16 pin header. This way there is no additional cost to allow for ICP.

BR Peg

0 Kudos