TBDML w/JB16

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

TBDML w/JB16

10,321 Views
admin
Specialist II
I have built a TBML using the JB16 and am having difficulty reporogramming the device.  If I use the object code provided with the CW project (see attached), I can program blank JB16's OK and the code runs normally.  When I try to compile the project, I get 2 errors referencing a #include in the MC68HC908JB8.c (#inlclude <MC68HC908JB8.h>).  After I change the library notation to local header notation (" ") the project compiles OK. 
 
However, when I reprogram the re-compiled code, I can not get back into ICP mode.  The program runs normally and will enumerate when connected to my PC.  If I pull PTA0 low while connecting the USB cable, I get an "Unknown Device" error from Windows.
 
Needles to say, USBICP.exe will not run.  According to app note AN2399/D, pulling PTA0 low forces ICP mode. 
 
I have attached the a zip file of the original project.  Any help or suggestions will be greatly appreciated.
 
Thanks
Spencer
 
Message Edited by t.dowe on 2009-10-22 10:53 AM
0 Kudos
Reply
8 Replies

1,443 Views
admin
Specialist II
BTW, I am using CW5.1 and the project was created with CW3.x.  I don't know if this will make any difference. 
 
Spencer
0 Kudos
Reply

1,443 Views
Alban
Senior Contributor II
Hello,

The trick allowing the JB16 to be programmed by USB is a bootloader programmed in the factory.
When you program something else in the flash, you erase the initial bootloader and replace it with your software.
The bootloader has disappeared and the only way to program the part again is to use Monitor Mode.

The other solution would be to modify the software to also include the bootloader.
This way, when you program the device via USB, you keep the USB JB16 bootloader.

Alban.
0 Kudos
Reply

1,443 Views
peg
Senior Contributor IV
Hi,
 
The comment by Alban is wrong (sorry mate!). The support for USBICP is built into the ROM. So you can't break it without breaking the device.
It tends to be a bit flaky though.
 
Did you see this thread?
 
You say TBDML and JB16 in the thread subject, original/genuine TBDML is JB8 (this may have confused Alban). The OSBDM is JB16 so search in this forum for other advise on this subject.
 
0 Kudos
Reply

1,443 Views
DanielM
Contributor III
Sorry mate, but Alban is right here (in principle) :smileyhappy:

The boot code itself is in ROM, but something needs to call it. It is called automatically in HW when the part is blank, but once you program the part for the first time it will never get called again unless you have support for this in the firmware.

I have created support for this in the ColdFire cable (TBLCF - see the coldfire forum), but as TBDML was not designed with JB16 its original firmware code does not have this support in it. You can easily re-use the boot code from the TBLCF and then you can even use my command line bootloader I have developed for the PC (no need to use the ugly application which comes with the appnote).

BTW, there is more things which need tweaking in the software than just the header files when porting to JB16. Two things spring to my mind right now:

1) more bdm_rx and bdm_tx routines will be needed to cover the crystal range down to 0.5MHz. If you do not create the additional routines the minimum crystal frequency the cable will support is 1MHz. Not a big problem I guess.

2) make sure you modify BDM.h. JB16 runs on 6MHz bus rather than 3MHz bus. If you leave the the original value in then the target speeds reported to the debugger will be off by factor of 2 and flash programming will have incorrect timing resulting in overstress and possible damage to the S12 micro. Once you do this, you will need to recalculate bdm_tx_sel_tresholds and bdm_rx_sel_tresholds - all values need to be divided by 2 I believe.

Daniel
0 Kudos
Reply

1,443 Views
peg
Senior Contributor IV
Hi Daniel,
 
Whilst I will admit that Alban may not have been 100% wrong his comment was far from correct. His basic premise was good in that the part could be programmed whilst blank but not be re-programmed and that this had to do with non-blank USBICP entry. However it went astray in the description.
 
The "bootloader" being referred to is one conditional jump into the ROM. Now only a real estate agent would call this a bootloader.
 
I have never heard of, or would expect anyone would bother to make this a seperate individually loaded piece of code to do this, nor that it was preloaded at the factory.
 
To Spencer: the jump you have identified is what I am talking about here.
 
Also, to enter blank part USBICP mode, it is not fully automatic, but requires the D+ line to be low on power up also.
 
Even slightly wrong or misleading information given to people struggling to get something done can be very frustrating and time-wasting for them.
 
To others: Please, if you believe someone's response to be wrong, misleading or whatever, make a comment about it. If nothing else it may promote an interesting educational discussion.
 
0 Kudos
Reply

1,443 Views
eckhard
Contributor V

Hello,

there was another problem concerning that the JB16 has less zero page RAM than the JB8, but there is a TBDML software version running on the JB16.
If I remember right, there is a problem with the USB firmare update in this software version but there were no firmware updates since this version.

Eckhard

 

tbdmljb16.zip

Message Edited by t.dowe on 2009-10-22 10:52 AM
0 Kudos
Reply

1,443 Views
admin
Specialist II
To all:
 
Thanks for the comments and info.  This gives me another avenue of investigation. 
 
Here is a code snippet from main which should jumpt to the ROM monitor if PTA0 is pulled low - at least that is what I expect to happen.
 
void main(void) {
//FOR USB LOAD DELETE IF NOT NEEDED
  POCR_PAP=1;                                    //pull up on port A
  DDRA = 0x00;                  //direction of the port A used to enter ICP mode
  if (!(PTA&0x01))                  //if port A0 is high then ICP mode
  {
   
    UCR3 = 0x04;                                  //internal pull up resistors enable
    asm{                     //enter ICP mode
    jmp 0xfa19;
    };                            
  }
//STOP DELETING!!!
However, when I pull PTA0 low the part does not jump.  The part does announce itself on the USB bus but does not ennumerate which gives the "Unknown Device" status.  BTW, UCR3 = 0x04 enbles the D- pull up. 
 
If I program the original .s19 (included in the zip file I posted yesterday), I am able to reprogram the device at will by pulling PTA0 low.  My problem appears when I recompile and load the new FW. 
 
This is very puzzling.
 
Thanks
Spencer
0 Kudos
Reply

1,443 Views
admin
Specialist II
Also, I am starting from the code that ECKHARD posted. 
 
Thanks again
Spencer
0 Kudos
Reply