Combined TBDML/OSBDM Code

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

Combined TBDML/OSBDM Code

23,485 Views
pgo
Senior Contributor V
Dear HCS12/HCS08 users,

I use a HCS12 processor board in undergraduate labs.  To support programming these we made a number of TBDML programmers.  It was reasonably straightforward to extend the use of these to HCS08 through some simple modification of the OSBDM code.  Unfortunately, this had the disadvantage of requiring the flash in the programming hardware to be changed when moving between programming HCS12 and HCS08 devices.

There has been some discussion on these forums about combining the OSBDM and TBDML code to produce a single more flexible programmer.

To make this easier I have produced a combined version of the TBDML/OSBDM code.  It is also necessary to have a modified windows driver file TBDML.dll so that Codewarrior will talk to the modified BDM which identifies itself as an OSBDM.  The OSBDM windows driver file remains unchanged since the software remains compatible with TBDML (at least as far as HCS08 devices).
This code is attached along with brief instructions.

Please let me know if this is useful or if you have other comments - preferably through this discussion board.

Good Luck!


USBDM_Snapshot_2008_2_19.zip


Message Edited by pgo on 2008-02-19 07:10 AM

Message Edited by pgo on 2008-02-19 07:10 AM
Message Edited by t.dowe on 2009-07-28 11:21 AM
0 Kudos
88 Replies

1,075 Views
pgo
Senior Contributor V

Dear vkojin,

 

I apologise - I somehow missed you query when originally posted.

 

I'm unsure what is happening here.  Could you please do the following to help track the fault:

 

Replace the DLLs with the debug DLLs supplied in the original Zip files.

Try the debugger as before.

The debug DLLs will create a log file in  C:\usbdm_dll.log.  Please post this log file.

 

What speed is the  MC9S08GT60CFBE operating at?

 

bye

 

PS. The  MC74HC125N is an unsuitable device since it does not allow operation between systems operating at different voltages.  A 74LV125A would be better.

 

0 Kudos

1,075 Views
vkojin
Contributor I

Dear pgo,

here, in Bulgaria, is very difficult to buy jb16 micros, and i already buy jb08.

and, in my case, i need to programm hcs 08 based modules (zigbee modules by Panasonic) and i'm not sure that TBDML work for me.

This project is very urgent for me, where i can find sollution for me?

 

0 Kudos

1,075 Views
byron
Contributor I

Dear pgo,

    Thanks for your reply. I will check our circuit carefully. :smileyhappy:

0 Kudos

1,075 Views
markslFS
Contributor I
Dear pgo,

Thanks for the feedback.


"If you are not using the 5V supply you  need an external diode instead."
I assume you mean "... not using the FET..."

"The BSS188 has a Vgs(th) of ~1V (1.4max)  so would be better for low target Vdd."
Since I can't get the BSS138, I assume the IRLML2502 is the best replacement: Vgs(th) of 0.6 to 1.2V. A bit overkill.

"The MAX9119 would be suitable I believe but it comes in a very small package?"
Indeed, it is a SC70-5, which is just over half the size of SOT23-5.

"This bead isn't really important and could be omitted if not concerned about interference (put a pad in and use a 0-ohm resistor initially)."
I'm using a 2-pin jumper footprint at the moment. The jumper would be removed to bypass USB power. I could easily put a low value wired inductor in the spot if circumstances require such.

Thanks,
Kevin

0 Kudos

1,075 Views
Macias
Contributor I

Dear Pgo,

Thanks for new software, but I still have this same problem. I modified USBDM_JB16.h file for my hardware, compile it, and upload to JB16. I trying it on my MC9S12NE64 using your Test_USBDM.exe and this is result of usage:
settarget 0
Executing:settarget 0
:setTarget 0
speed 25
Executing:speed 25
Setting speed failed
Speed = 25.00 MHz (614 ticks, sync=10.2 us)
connect
Executing:connect
:connect - Failed
Status = Wait, Not Connected, Reset
Speed = 15360.00 MHz (1 ticks, sync=0.0 us)

I can't change speed for hcs12 nad hcs08.
My hardware is identical like presented in this file: TBDML_JB16_SOIC28(Minimal).pdf
I try to compile your software in TBDML mode, but result is the same.
I see something interesting until programming JB16, when I use this: Re-programming_BlockErase.imp and select another software version it not change, but when I use: Initial_Programming_MassErase.imp software in jb16 was changed correctly.

I attache my USBDM_JB16.h file, if you cane pelase check it that is correct for my hardware.

Best Regards,
Maciej Bojczuk

 

USBDM_JB16.h

Message Edited by t.dowe on 2009-08-31 02:27 PM
0 Kudos

1,075 Views
pgo
Senior Contributor V
Dear Macias,

Please base your modified header file on the TBDML_JB16.h (It shouldn't need any changes - check it against the hardware circuit) or use the corresponding flash file that is included in the ZIP files.

To debug the hardware do the following:

Run test_USBDM.exe

Type the following commands:
=======================================
settarget 0   -- and then complete the dialogue
connect
gs
exit
=======================================

Post here the usbdm_dll.log file produced in the root directory of the C: drive.  This should give some hint of what is wrong.

bye

PS.  I have tried the TBDML basic hardware with a NE64 and it operated fine.



Message Edited by pgo on 2009-01-31 01:08 PM
0 Kudos

1,075 Views
Macias
Contributor I
Dear Pgo,
Thanks for replay.
I checked USBDM on hcs12 (mc9S12NE64) target was recogniezed but, USBDM (in tbdml mode) throw me an error until doing ereasing flash. I need usbdm for only 5V targets and I have problem with same components (I can't buy it in Poland). I wil try to build complete usbdm. When you can share new software version? I've last question, it is possible to replace JB16 SOIC28 into JB16 Soic20?


PS.
Sorry for my English

Best Regards,
Maciej Bojczuk

0 Kudos

1,075 Views
Macias
Contributor I

Dear Pgo,
Please tell that is possible to run your USBDM on this hardware:

http://www.freescale.com/files/community_files/OSBDM08/USBDM_JB16_SOIC_JB16JDWE.pdf

(JB16 SOIC20 + 74HCT125)
And my second question is connected with target, USBDM support MC9S08JM60 device?

Best Regards,
Maciej Bojczuk
http://forums.freescale.com/attachments/freescale/TBDML/305/2/USBDM_JB16_SOIC_JB16JDWE.pdf" target="...

Message Edited by t.dowe on 2009-08-28 05:24 PM
0 Kudos

1,075 Views
pgo
Senior Contributor V
Dear Macias,

The hardware should be compatible but is untested.  It will have reduced functionality as compared to the complete USBDM as it does not have target power supply monitoring which is desirable for HCS08 targets.

With the above limitations it should work OK with a JM60 but may have some problems getting the target into BDM mode in some situations.

The next version of the USBDM software will have a software workaround for this deficiency.

bye

0 Kudos

1,075 Views
enrico
Contributor I
Dear pgo,
Thank you very much for your work and support!

I have a question: on TBDML schematic, and also on your USBDM schematic,
there's no pull-up resistor between D- and VReg output (pin 4) of JB16 MCU.
I've read that USB 2.0 specification require that a low speed USB device
(such as the USB module of JB16)  is terminated by a 1.5K pull-up resistor on D-,
as in the original OSBDM08 schematic (on that schematic, the resistor can be
temporarily disconnected to allow entering ICP mode).
How TBDML and USBDM devices can be correctly recognized by the host
without the pull-up?

Thank you
0 Kudos

1,075 Views
pgo
Senior Contributor V
Dear Enrico,

The JB16 has an internal programmable 1k5 resistor.  The use of an external resistor is optional.  The USBDM software has an option to support both possibilities.

bye



Message Edited by pgo on 2009-01-26 11:17 AM
0 Kudos

1,075 Views
enrico
Contributor I
Ok. Thank you!
0 Kudos

1,075 Views
josh12
Contributor I
Hi pgo!
 
I have a question about bdm Rx&Tx  route. In your program you use something number such as (2,2,12) to calculate the which BDM freq this program can communicate with.For JB16  6*(11~14)/4 = 16.5~21
am I right? what the Number 12 will effect?(speed).
If  want to change the Freq range , can I just add nop between driver Data to BDM and driver BDM to high.
 
my code:
   asm
   {
      BDM_ENABLE_ASM_TX
      //LDAA #bitCount
     
      SEC
      //ROL  bitCount
      ROLB                               
     
   Loop:
      BCS IsOne                   //[3],bra 3c,not bra 1C,so add nop nop
      NOP
      NOP
   IsZero:
      BCLR BDM_PORT_Tx, (1<<BDM_OUT_BIT)   //[4]  Driver BDM low
                                           //---11
      BCLR BDM_PORT_Tx, (1<<BDM_OUT_BIT)   //[4]  Driver Data(0) to BDM
                                           //---4
      BSET BDM_PORT_Tx, (1<<BDM_OUT_BIT)   //[4]  Driver BDM high
                                           //---4
      ASLB                                 //[1]
     
      BEQ Done                             //[3]
      NOP
      NOP
     
      BCC IsZero                           //[3]
      NOP
      NOP
     
   IsOne:
      BCLR BDM_PORT_Tx, (1<<BDM_OUT_BIT)  //[4]
                                          //---11
      BSET BDM_PORT_Tx, (1<<BDM_OUT_BIT)  //[4]
                                          //---4
      BSET BDM_PORT_Tx, (1<<BDM_OUT_BIT)  //[4]
                                          //---4
      ASLB                                //[1]
     
      BNE Loop                            //[3]
      NOP
      NOP
     
   Done:
      BDM_3STATE_ASM_TX                   //[4]
            
   }
 
I use UF32 bus Freq is 30MHz,so the BDM Freq is 41.25~52.5MHz,am I right. Can I just add nop?
Thanks for your help.
0 Kudos

1,075 Views
pgo
Senior Contributor V
Dear Josh12,

There is a spreadsheet "HCS08 JB16 BDM Timing.xls" included in the source which calculates the frequency range of each set of timing values.  This should be updated for the UF32 clock frequency then new values may be determined.  The routines would then be redone for these updated timings.

The individual instruction cycles need to be taken into account and these are significantly different for the HC12 versus the HC(S)08.  Detailed coding also differs.

Attached is a partially updated BDM.c for the UF32 & the spreadsheet.  I have not checked these and some measurements need to be done to determine the correction factor used in the spreadsheet.


bye



Message Edited by pgo on 2008-10-14 03:21 AM

Message Edited by pgo on 2008-10-14 03:23 AM

 

Temp2.zip

Message Edited by t.dowe on 2009-08-31 02:15 PM
0 Kudos

1,075 Views
pgo
Senior Contributor V
Dear All,

Latest update of the USBDM software.



Message Edited by pgo on 2008-10-28 02:00 AM

Message Edited by pgo on 2008-10-28 02:00 AM

 

1. Installation.zip

2. Source.zip

3. PCB.zip

 

Message Edited by t.dowe on 2009-08-31 02:08 PM
0 Kudos

1,075 Views
pgo
Senior Contributor V
Dear All,

February release of USBDM for JB16.

Enjoy!

You might also be interested in the JMxx version:

Combined TBDML/OSBDM Code for the JM16/32/60 (USBDM)

Revision History

  • V1.4 (February 2009)
    • Added extra dialogues prompting the user to cycle target power when necessary. Corresponding options added.
    • Added connection retry when target power is absent.
    • Added support for MC51AC256 (a bit of a hack!)
    • Modified HCS macros (to provide considerable size reduction as needed for USBDM_CF in 16K)
    • General clean up of code
    • Unified Timer MACROS
    • Re-arrangement of Target Vdd control routines
    • Minor mods & corrected comments in bdm_syncMeasure()
    • Reviewed stack size
    • Increased bdm_status.waitX size
  • V1.2 (October 2008)
    • Removed library reference in ICP code - ICP broken when non-ICP code was changed! This update requires the ICP code to be replaced when updating any code.
    • Increased stack size (stack overflow was possible)
    • Utilities (setBoot) updated to match.
    • Other cosmetic changes
  • V1.1 (August 2008)
    • Vista compatibility
    • Fixed several bugs related to use of 1T45 buffers (Witztronics etc.)
  • V1.0 Initial Release




Message Edited by pgo on 2009-02-05 03:18 PM

 

1. Installation.zip

2. Source.zip

3. PCB.zip

Message Edited by t.dowe on 2009-08-31 02:11 PM
0 Kudos

1,075 Views
chiusir
Contributor I
Thanks for pgo's great word!
Last week I have programmed the JB16 USBDM sucessfully.But I found that I could not programm a blank JB16DWE directly. After I programmed it through MON08,PC host can recognize ICP mode.Otherwise,PC recognized USB device as "unknwon device" instead of "ICP device".What's the reason?
Thank you again!
0 Kudos

1,075 Views
pgo
Senior Contributor V

Dear chiusir,

I'm having trouble understanding what you mean!

Could you try the following (and report results)?

Completely erase the JB16 (using MON08 if necessary).
Confirm ICP operation using the Freescale ICP software.  This will confirm the basic USB interface.
Use the ICP software to download the appropriate USBDM image to the JM16.
Reconnect and describe the results!

It is necessary to have the Special Edition: CodeWarrior for Microcontrollers installed for the correct driver to be available. (Not the Special Edition: CodeWarrior for HCS12(X) Microcontrollers version though it will then work with this as well provided the above version is installed as well).

bye

Message Edited by pgo on 2008-12-24 12:31 AM

Message Edited by pgo on 2008-12-24 12:31 AM

0 Kudos

1,075 Views
chiusir
Contributor I
Dear pgo,
      Thank you for your reply!
      I have made a USBDM with JB16DWE.It works  smoothly,but it can't soft reset the the target occasionally and then an error will stop the download process next time.
      So ,I think I should change JB16 to JM60 now.
      Merry Christmas!
                                                                                            chiusir  
0 Kudos

1,075 Views
pgo
Senior Contributor V
Dear chiusir,

Follow-up.

The following thread may be relevent:

error message : Error in calling open_device()!

bye


Message Edited by pgo on 2008-12-24 07:05 AM

Message Edited by pgo on 2008-12-24 07:05 AM

Message Edited by pgo on 2008-12-24 07:06 AM
0 Kudos

1,074 Views
josh12
Contributor I
Hi pgo,
I have a question about your code .In your code you use USB EP0 to transfer data,this is a control EP,
why not use EP2(you have alreay write the EP2 Tx&Rx Code),EP2 is bulk EP,speed is much more faster. At last ,Can use EP2 & EP0 work together, EP0 transefer CMD,EP2 transfer DATA(such as S19 file or memory block data)?
thanks for help
0 Kudos