USB with MC68HC908JB8

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

USB with MC68HC908JB8

15,106 次查看
maite
Contributor I
Hello,
 
I am trying to develop a USB Human Interaction device using the MC68HC908JB8 microcontroller, and I'm getting some problems with it. When I have the program running, the PC host detects my device, but there's something wrong with it because it says that the device can't initiate. Has anyone developed succesfully one of such devices using this microcontroller? Thanks!
标签 (1)
0 项奖励
回复
20 回复数

1,757 次查看
Tumma
Contributor I
Hi all,
             I am working with MC68HC908JB8http://forums.freescale.com/message?board.id=8BITCOMM&message.id=563" rel="nofollow" target="_blank  for USB keyboard. I have done the usb part and it is detected also. For that  I have assigned standard keyboard vendor id etc. After adding my key detection part my program is behaving erratically.

I have include my key detection and it has to be transmitted.Nothing is happening. It is giving timeout error. I have one doubt in this regard.In the referece code given for  MC68HC908JB8 , in DRM002 document, How first in transaction will happen? what I have seen (there) is after transmit flag is set then we will send next transactions.

How initially, this first transaction  is happening?
Can any tell me how intially transactions have to taken care.

Can any one tell me how to the things which are related to driver side.

Thank you ,
0 项奖励
回复

1,757 次查看
eckhard
Contributor V
Hello,
 
DRM015 has a HID implemented in Assembler. DRM014 has a HID too.
I think that I remember that one document references an USB lib availible from Freescale on request.
 
Eckhard
0 项奖励
回复

1,757 次查看
mo
Contributor I
Hi eckhard,
How did you request the USB lib from freescale.com. Did you have to call them? Do you happen to have it and know if it is in C, not assembly. I'm currently trying to get USB communications for MC68HC908JB16 working, but having some trouble, even with the code posted below. thanks.

Mo
0 项奖励
回复

1,757 次查看
JayJay
Contributor I
Due to the number of request for the HID code, I managed to find a place for the files. Here it is: -
 
 
The zip contains HID keyboard emulation in C as a Codewarrior 3.0 project file.
 
HTH
Jay
0 项奖励
回复

1,757 次查看
AHoyle
Contributor I
Hi Jay

Thanks very much for the HID code. It's a great starting point. Just what I have been looking for. I slightly modified it to work with Codewarrior 5.0. I have attached it to this message because I don't have any where to post it. May be you could post it on your site for others to access.

Thanks
0 项奖励
回复

1,757 次查看
mo
Contributor I
Hi Jay and AHoyle,
Thanks for posting the code. I am trying to use a JB16 and I have everything setup correctly such as the interrupt handler USBisr(), but for some reason it doesnt send any descriptors to the host. I just want to know if this code is complete (as in when the microcontroller is plugged into the host, should the host be able to recognize the device, and not barf). Thanks for any help.
mo
0 项奖励
回复

1,757 次查看
AHoyle
Contributor I

Hi Mo

I just took Jay's code and tweeked it to work on code warrior 5 (I am using a MC68HC908JB8). Once it compiled I just plugged it into my USB port and it worked. Unfortunately, I am still new to programming HID devices and I am trying to understand how they work myself, so I can't really help.

However I have found a realy utility for writing the HID descrition reports on www.usb.org/developers/hidpage. Also see www.lvr.com/hidpage.htm has a lot of good information.

Sorry I could not be more help

0 项奖励
回复

1,757 次查看
mo
Contributor I

Hey everyone,
thanks to the code above I was able to complete my USB project. As you know I am using JB16 instead of the JB8. What I had to do to get the code to work for the JB16 was to make a new project in Codewarrior and then add the files from the JB8 project...the memory map was different.
I have attached my code if any one is interested.
All the commented out code in main.c is for my device.

Alban removed potentially injurious content from the attachement. Also fixed software to compile under CW3.1 (T0SEQ TOSEQ)

Message Edited by Alban on 04-24-2006 08:28 AM

0 项奖励
回复

1,757 次查看
srpollo
Contributor I
Thans for post the code. Its resolve my problem
0 项奖励
回复

1,757 次查看
irob
Contributor V
Hey guys, have any of you used the JB1/8 to implement a USB mouse?  I know this sample software implements a keyboard.  Should be fairly straightforward in changing it into a mouse, right?

Well, not if you're new to USB and HID code!  Yikes, complicated.  :smileyhappy:  Just curious.
0 项奖励
回复

1,757 次查看
irob
Contributor V
Hey folks, I have this project modified for a generic 3-button USB mouse now.  For the direction axes, I'm just using a set of four push buttons on Port A.

It's enumerating correctly to Windows, which is a good first step.  But what's not working yet is any of the data.  It's not at all clear from the many USB documents (See of course the USB Spec v1.1, the HID Usage Tables v1.12, and Device Class Definition for HID v1.11) how exactly this data must be formatted.

Just from the previous CodeWarrior design "HID-kbd", it's clear that data is sent out on the UE1D[0:7] data bytes.  But for a mouse, these aren't doing anything.

Here is my ReportDesc:

Code:
const byte ReportDesc[]={  0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)  0x09, 0x02,                    // USAGE (Mouse)  0xa1, 0x01,                    // COLLECTION (Application)  0x09, 0x01,                    //   USAGE (Pointer)  0xa1, 0x00,                    //   COLLECTION (Physical)  0x05, 0x09,                    //     USAGE_PAGE (Button)  0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)  0x29, 0x03,                    //     USAGE_MAXIMUM (Button 3)  0x15, 0x00,                    //     LOGICAL_MINIMUM (0)  0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)  0x95, 0x03,                    //     REPORT_COUNT (3)  0x75, 0x01,                    //     REPORT_SIZE (1)  0x81, 0x02,                    //     INPUT (Data,Var,Abs)  0x95, 0x01,                    //     REPORT_COUNT (1)  0x75, 0x05,                    //     REPORT_SIZE (5)  0x81, 0x03                     //     INPUT (Cnst,Var,Abs)  0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)  0x09, 0x30,                    //     USAGE (X)  0x09, 0x31,                    //     USAGE (Y)  0x15, 0x81,                    //     LOGICAL_MINIMUM (-127)  0x25, 0x7f,                    //     LOGICAL_MAXIMUM (127)  0x75, 0x08,                    //     REPORT_SIZE (8)  0x95, 0x02,                    //     REPORT_COUNT (2)  0x81, 0x06,                    //     INPUT (Data,Var,Rel)  0xc0,                          //   END_COLLECTION  0xc0                           // END_COLLECTION};

 Since this is configured for relative axes movement, I figured that simple incrementing and decrementing would work:

Code:
    if (BUTTON8==CLOSE)    {      UE1D1 += 1;   // +X axis      LED = ON;    }    if (BUTTON6==CLOSE)    {      UE1D1 -= 1;   // -X axis      LED = ON;    }

 
...and so forth.  Is this a bad assumption? Any thoughts on what the data should even look like?
0 项奖励
回复

1,757 次查看
irob
Contributor V

irob wrote:
Hey folks, I have this project modified for a generic 3-button USB mouse now... Since this is configured for relative axes movement, I figured that simple incrementing and decrementing would work.  Is this a bad assumption?

As it turns out, that was a horrible assumption!  With much trial and error (man, the various USB and HID specs are not very great for explicitly outlining the data format), I determined the following:

UE1D0   mouse buttons, (bit 1 = left click, bit 2 = right click)
UE1D1   x axis movement
UE1D2   y axis movement
UE1D3   mouse wheel scroll

The direction bytes need to be signed integers.  Assigning a value of 1 to either will move in the positive directions.  An integer multiplier value of x will move x times as fast.  Same rules apply to the scroll wheel byte.

The mouse buttons are tied to bits of the data byte.

I couldn find none of the above in any USB publication.  I determined them all by trial and error.

What isn't clear to me is how to send non-integer (i.e., fractional) values for axis movement on the data bus. I've tried, but it doesn't seem to work.

Esthetically, a value of "1" moves at a pretty fast speed on my computer.  Yet my Dell optical mouse is able to move as slightly as I want it to.

Does anyone have suggestions on how to send fractional data on the USB bus?  Or for that matter, what the official data bus format is?
0 项奖励
回复

1,757 次查看
JimDon
Senior Contributor III
If you can make the X and Y be more that 8 bits, the a 1 would be a smaller fraction of the whole.

0 项奖励
回复

1,757 次查看
srpollo
Contributor I
Hello,
I'm interesting in post your code because I dont know why my proyect does not work. Using the processor expert, I inicializated the usb and it only work when I connect the monitor cable.

I have to divide de clock frequency??a warning said me that the usb work on 6MHz and my design has 12MHz

Thanks
0 项奖励
回复

1,757 次查看
peg
Senior Contributor IV

Hi mo,

Are you trying to load the code posted by AHoyle into a JB16?

It is for a JB8!

I tried it as the JB16 is an extension of JB8 and most JB8 stuff is the same in the JB16. It didn't work! Did you modify it for JB16. I don't know if you have to.

BR Peg

0 项奖励
回复

1,757 次查看
mo
Contributor I
Hi,
Yes I am trying to use it for JB16.
I didnt really modify it for the JB16, I changed the .h and .c files that it referenced because the memory locations of the registers are slightly different, but the names are same. For me I am pretty sure that the problem is coming from the function do_setup() in usb_lowlevel.c and the line:
SetupBuffer = *(setup_buffer *)(&UE0D0);

this causes problems for SetupBuffer.wValue.hi which is called in getDescriptor(). Do you know of a better way to do this, because I always endup in the default case.
0 项奖励
回复

1,757 次查看
maite
Contributor I
Thanks a lot to everybody! The code from Jay was very helpful. It's what I needed, I think that I had a problem with the report descriptor.
 
Maite
0 项奖励
回复

1,757 次查看
eckhard
Contributor V
Hello,
here is a reference design ( DRM002 ) i think. It is the rom elmicro.
You can get the software to operate the JB8 out of that refenrence design. You an it at the JB8 Product or here. http://www.freescale.com/files/microcontrollers/doc/ref_manual/DRM001.pdf

I don´t know if the software can be downlaoded or if you just have to cut and paste it.

Eckhard
0 项奖励
回复

1,757 次查看
JayJay
Contributor I

The DRM002 ref design does not use HID, it implements a simple 8 byte transfer using Thyscon driver on the PC side.

I do have HID code which emulates a USB keyboard. I dont have a place to host it, if someone offers to host it I can put it up or send me an e-mail at hc08jb8 at y.a.h.o.o.c.o.m

HTH
Jay

 

 

 

0 项奖励
回复

1,757 次查看
joerg
Contributor II
Hi matie
have a look at the open source BDM. Ther you can find the source code. They are using the USB interface.

Saluti joerg
0 项奖励
回复