USB code for HC08

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

USB code for HC08

13,987 Views
mo
Contributor I
Hi guys,
I'm kinda new here, but I was wondering if anyone had tried to use the MC68HC908JB16JDW chip. I have figured out how to program it correctly entering ICP mode etc. It is a USB chip, so now I'm trying to get some USB code preferably in C, to make a keyboard like device. I found some assembly files on this site, but I cant find anything useful. Any help would be appreciated.
thanks.
mo
Tags (2)
0 Kudos
18 Replies

1,853 Views
RockyRoad
Contributor III

peg -

The Hong Kong team has looked into this again and believe that they have the solution.

They found that during USB enumeration, the reset pin on the JB16 is oscillating. They found that putting a capacitor of at least 330 nF from the reset pin to ground solved the problem. They also tried and are suggesting using 1uF as the 'production' value.

I haven't been able to actually try this here, but I'm passing it on so that you can try it. I will be building a couple of more boards in the next few days and plan to add this.

- Rocky

0 Kudos

1,853 Views
peg
Senior Contributor IV

Hi Rocky,

I just discovered this oscillation on the reset pin about one hour ago, but rather than trying to kill it I have been trying to find the reason.

Here is what I have found:

Start a blank JB16.
Execution starts from the monitor mode reset vector at $FEFE which is $FE10.
0000FE10 A7FA     AIS    #$FA   ;don't know
0000FE12 1100     BCLR   0,PORTA  ;why?
0000FE14 CDFA07   JSR    $FA07   ;jump to near top of MON ROM 1 to see if USB Monitor
;
0000FA07 070809   BRCLR  3,PORTE,*+12       ;abs = $FA13 branch if D+ low USBICP!!!!!
0000FA0A 3F38     CLR    UADDR  ;disable USB
0000FA0C 6EFF80   MOV    #$FF,$80 ;RAM0 = $FF
0000FA0F 45FFF6   LDHX   #$FFF6  ;TIM1 Int Vector
0000FA12 81       RTS   
;
0000FA13 C6FFD0   LDA    $FFD0   ;Check Ext Security 2 USBICP
0000FA16 4187F1   CBEQA  #$87,*-12       ;abs = $FA0A No USB if sec2 set
0000FA19 9B       SEI      ;mask ints
blah, blah, blah

So very quickly after it starts it checks for USB D+ being low (which is the only condition required other than blank)
If it is low, it checks that the extended security has not been set then gets to address $FA19.
$FA19 is the entry point that is used by AN2399 and also where the OSBDM code jumps to if the PORTD bit 3 jumper is on.

Now the strange thing is if you jump to $FA19 from a user programme in FLASH everything works very reliably.
If you let it get there via the monitor code it doesn't.

Also jumping straight to $FE10 from a user programme works OK as well

The only pre-requisite is to disable the COP.

The reset pin is going low for a double pulse every 150us when entered via monitor entry.

A 0.1uf makes it all work for me. But why doesn't the problem occur when entered from user mode?
Here is my test programme:

 ORG $BA00  ;start of FLASH
 BRCLR 3,$03,COP ;if jumper on don't disable COP
 MOV #%00000001,$1F ;disable COP
;COP JMP $FA19  ;jump to ICP entry in Monitor that AN2399 uses
COP JMP $FE10  ;jump to monitor entry point that blank reset vector uses

 ORG $FFFE
 DW $BA00  ;set reset vector to start of FLASH

BR Peg

0 Kudos

1,853 Views
RockyRoad
Contributor III
peg -
 
Just back from an extended weekend...
 
I finished building two more OSBDM and I'm able to play with one of them. I don't have a lot to add to what you found, but I'll add what I've seen so far on my board.
 
The 1uF capacitor suggested from Hong Kong doesn't work on my board. Your 0.1uF does work.
 
With 1uF, I still see 4 low pulses on RESET spaced about 150 msec apart. Windows responds with USB device error message.
 
With 0.1uF, I see 2 low pulses on RESET that are only spaced about 60 msec apart. Windows goes to the found new hardware dialog box.
 
I can't explain (yet) the 10X difference in capacitor suggested and required and the workings of the Monitor ROM.
 
I'll look at it some more tomorrow.
 
- Rocky
0 Kudos

1,853 Views
admin
Specialist II
Dear Rocky,

I've recently assembled a hybrid BDM module - using the TBDML V1.0 hardware and a modified OSBDM firmware - and used it to reprogram a MC9S08GT60CFB-based RF board from DLP Design.

My question is: assuming you wrote the OSBDM code which I modified, do you have any problem with me offering BDM modules (based on the modified firmware and GDI libraries) for sale?

I've received the OK from Daniel wrt the TBDML hardware...

Sincerely,
Kevin
0 Kudos

1,853 Views
RockyRoad
Contributor III
Kevin -
 
Sorry for the late response. I wasn't monitoring old threads and one of the other moderators had to point out your posting.
 
I was part of the team that developed the OSBDM. I worked on the hardware.
 
You may use modified versions of the OSBDM firmware and the GDI in your product.
 
- Rocky
0 Kudos

1,853 Views
mo
Contributor I
i got USB working for JB16, the code that is given in TestHID.zip has to be remade from scratch for the JB16...otherwise the memory mapping is off slightly.
- mo
0 Kudos

1,853 Views
mo
Contributor I

HI,

yes i got that to work peg. if you still might need help...just post here again

mo

0 Kudos

1,853 Views
peg
Senior Contributor IV

Hi mo,

Yes please, I still can never get blank part USB ICP to work.

I can programme it over MON08.

I can use it to programme something else.

I can bring it up into the ICP mode via grounding D3.

This is actually nearly exactly the same as the blank part startup after examining the monitor code.

Please let me know how you do it, although it may not help me as I am getting different reports from several places that its very flaky (getting it to boot into ICP mode).

BR Peg

 

0 Kudos

1,853 Views
mo
Contributor I
Hi, I'm programming through USB, it is the special USB chip. I dont know if you are doing through USB. If you are then I can help you.
There is a document called AN2399.pdf and software AN2399SW.zip that are avialable on this website.
0 Kudos

1,853 Views
peg
Senior Contributor IV

Hi mo,

I am not sure if your understanding me.

I am talking about a JB16 either "out of the box" or "virgin" or a recently "mass erased" one. Then connecting it to a PC via just a USB cable (no special programmer) (no code in the flash).

BR Peg

 

0 Kudos

1,853 Views
mo
Contributor I
ok, thats what I had, um...you have it wired correctly I am assuming, because I dont know the wiring myself, someone else did it for me. For the programming portion, once the device connects to the PC the windows will say new USB device detected. To install the drivers for this download AN2399SW.zip file. Once you have this file and AN2399.pdf follow the simple instructions to install the driver.

Once the driver is installed you can open up USBICP.exe file. This program lets you program through USB. Dont program anything into the chip just yet. If you understand me up to this point, then good otherwise I'll try to explain better.
0 Kudos

1,853 Views
peg
Senior Contributor IV

Hi mo,

Thanks for your help.

I have got the ICP PC programme working etc. I can use it to do a mass erase after powering up a programmed OSBDM with the D3 link on.

What my problem is, is that I get device not recognised (by PC) when I power back up erased. I have the 1k5 removed and both USB lines pulled down.

Actually according to the monitor, you can leave the 1k5 in situ.

It appears to start to work as the internal pullup is applied but the computer doesn't recognise it now.

I am leaving my computer now so don't expect a reply for several hours.

BR Peg

0 Kudos

1,853 Views
mo
Contributor I
Hi,
I am not sure where exactly you are judging from your technical language
I have no idea what OSBDM is, or what D3 link means.

So when you program the device the first time through USB ICP, I think it is necessary to put ICP determination code also.

To reenter ICP mode what I had to do was pull PTA0 to 0 after removing it from USB connection and then before reconnecting it back to the PC. This allowed me to reprogram the chip after programming it.
This
0 Kudos

1,853 Views
peg
Senior Contributor IV

Hi mo,

Sorry, the OSBDM (Open Source Background Debug Module) is what I am working on. It is a USB based programmer for 9S08 devices. The project is available here under the "8-bit Microcontroller Community" at the top right of this page. You may want to take a look at it.

D3 is bit 3 of PORTD and is the same as bit 0 PORTA in the AN2399 example.

I can do what you say about powering up with the link fitted and it works.

But if I mass erase it then power down. (perhaps accidently) now if I power back up with blank FLASH and USB D+ pulled to ground it should still come up like after the jumper is installed on a programmed device. But I and many others are having a problem here. It seems to be resolved now, see later in this thread.

 

Thanks, Peg

 

 

Message Edited by peg on 04-14-200603:52 PM

0 Kudos

1,853 Views
peg
Senior Contributor IV
Hi mo,
Perhaps you can help me?
I have been struggling for two weeks to get my JB16 to do blank part USB ICP.
If you have achieved this can you tell me how you did it?
 
I have now resorted to disassembling the Monitor code in order to figure out how it is supposed to work, due to lack of documentation and help available.
 
BR Peg
 
0 Kudos

1,853 Views
Alban
Senior Contributor II
Hi Peg,
Sorry to hear this...
Have you tried to enter a formal Service Request through the system ?
This way should be more efficient when the info missing or the problem stalls a project !
 
Cheers,
Alban.
0 Kudos

1,853 Views
peg
Senior Contributor IV

Hi Alban,

Rocky is following this up for me with Hong Kong.

Not sure why he only PM'd me about this.

BR Peg

 

0 Kudos

1,853 Views
Alban
Senior Contributor II

Hi Mo,

I'm pretty sure the DRM055 is exactly what you are looking for.
This is a
Reference Manual on how to use a QT and JB for USB Wireless keyboard...

Cheers,
Alban.

0 Kudos