LPC1769 USBHostLite

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

LPC1769 USBHostLite

5,088 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tybls on Wed Jun 22 14:32:00 MST 2011
I am developing a USB device that will write data to a flash drive. This requires the USB device to act as the host. The nxp example USBHostlite is the obvious starting point. In the example description the Keil MCB1700 board is used to run the example. My question is whether or not the the example can be run without the Keil board, and if so whether or not I need to modify the code.

The goal for now is to simply write a few lines of random numbers as a demonstration to a text file on the flash drive.

Info:
Windows X SP3
LPCXpresso LPC1769 REV B
IDE version: LPCXpresso v3.6.3
22 回复数

4,775 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by stalisman on Mon Jan 30 04:38:25 MST 2012
Nothing with USB is ever straght forward due to the mass of information that needs to be be picked through.

The following link has a lot of valuable information presented in a way more easily understood than the official documents.

http://www.usbmadesimple.co.uk/

Sections 4 and 5 are relevant in order to understand the full context.


I ought to add that understanding the report syntax is a hurdle in its self..here is another link I googled at random ...

http://www.frank-zhao.com/cache/hid_tutorial_1.php
0 项奖励
回复

4,775 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by YASIRALI on Fri Jan 27 20:37:25 MST 2012
Hi,

I have worked with NXP USB host lite example and successful tested it  for my USB stick ,now i want to change the code for HID class as it is  mean for Mass storage Class only .
By studying i come to know that i have to do two things
1.Change the BULK descriptor to INTERRUPT for HID
2.Support for Report parsing

but i do not know how to do these?
any body done this please guide me how to do this ,i am targeting the LPC1754 from NXP
0 项奖励
回复

4,775 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by YASIRALI on Wed Jan 25 05:31:20 MST 2012
i have also checked the voltage gnd ,+5v is ok and at D+ we have 2.56 v when ulink2 is busy or stucked and on D-  i have zero volts .
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by YASIRALI on Wed Jan 25 05:29:11 MST 2012
Hi,
to all please help me i have checked the nxp usb host lite example with ulink 2 debugger,its gets stuck at

void  Host_WDHWait (void)
{
  while (!HOST_WdhIntr) {
    ;
  }
  HOST_WdhIntr = 0;
}

my hardware is attached ,i think that hardware is correct ?then where is the problem??
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marius05 on Mon Jun 27 08:19:18 MST 2011
You were right, MEA CULPA!
I checked everything. And I switched D+ and D-...
Thank you very much,
and sorry for stealing your time...


Quote: Zero
Obviously your enumeration fails in HOST_GET_DESCRIPTOR  :eek: and therefore I still think you have a hardware problem :mad:

Even with a wrong USB stick or FAT32, USB should try to enumerate and your scope should show a few signals...

0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 27 07:39:15 MST 2011
Obviously your enumeration fails in HOST_GET_DESCRIPTOR  :eek: and therefore I still think you have a hardware problem :mad:

Even with a wrong USB stick or FAT32, USB should try to enumerate and your scope should show a few signals...
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marius05 on Mon Jun 27 07:20:12 MST 2011
Ok,
I still have not switched the resistors. I will try this next.
When I go to debug mode, the processor stays in following loop:

void  Host_WDHWait (void)
{
  while (!HOST_WdhIntr) {
    ;
  }
  HOST_WdhIntr = 0;
}

And returns the error "ERROR: In Host_EnumDev at line 360 - rc ="

I am using the LPC-Xpresso powered by Laptop USB.
USB_socket is powered by external hardware


Quote: Zero
And then test wrong 30k and...

:confused:

...damned, it's also working with wrong 30k :mad:

0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 27 02:29:50 MST 2011

Quote:

...So use the correct values first...

And then test wrong 30k and...

:confused:

...damned, it's also working with wrong 30k :mad:
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Mon Jun 27 02:20:57 MST 2011
Pull down resistors value is probably important. They are not simple pull-down which could be replaced by any value between 1k and 1M. The USB device has a 15k pull-up on one line to say "hello, I am an 1.5 Mbit/s device" (12Mbit/s if connected on the other line) before transmission starts. Voltage read by the controller through this divider is probably important and defined by USB standard. So use the correct values first.

Angelo

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 27 01:23:41 MST 2011

Quote:

...there are no signals...

1. No USB signal = no USB :eek:

2. What's UART messaging?

3. Did you use debugger to see if Host_EnumDev() is looping somewhere?

4. Are we talking about LPCXpresso or your own hardware?

BTW: FAT16 could have 63000 [COLOR=Red]cluster[/COLOR] (32768 bytes) with 64 sectors (512 bytes) per cluster
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marius05 on Mon Jun 27 00:52:38 MST 2011
Hello again,

yes, I have an external Power supply with exact 5V. GNDs of LPC-Xpresso an of the power supply are connected. The USB socket ist connected with the LPCXpresso 1768 with 33R Series and 30K (I had no 10K resistor here) to the GND.
As USB Stick I use a common 2 GB Stick, formated in FAT (at Windows 7). It has ca. 63000 Sectors, so I would guess that it is formated in FAT16.

If I connect the oscilloscope to the USB Data Lines, there are no signals.


Quote: Zero
Tips:

1. Check your USB Host power supply :)

2. Provide more information about whatever you connected to USB Host :eek:

0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Jun 25 09:56:12 MST 2011
Tips:

1. Check your USB Host power supply :)

2. Provide more information about whatever you connected to USB Host :eek:
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marius05 on Sat Jun 25 09:38:30 MST 2011
Hello,

I have exact the same Problem.
And even with your tips, I still don't manage to get it work.
But I don't have got an UART connection. I will add it as soon as possible.

Hope there are coming more tips.

Bye
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mike31416 on Fri Jun 24 03:49:39 MST 2011
I found a few problems with the usbhostlite example from lpc1768_xpr_bb_110111.zip. There a a few mistakes in usbhost_fat.c with the filename parsing and the detection of an available FAT entry.

Using certain file names such as FILE0001.TXT did not work and a freshly formatted usb drive would not work unless a few files were first created and then deleted (would set the first byte of the FAT entry to E5 from the original 0 value).

Here are my changes:


For FAT_GetSfnExt() (problems if extension all spaces):
#ifdef MBCHG
for (cnt = 0; cnt < 3; cnt++)
{
if (entry[8+cnt] == ' ')
{
break;
}
else
{
*ext_ptr++ = entry[8+cnt];
}
}
*ext_ptr = 0;
#else


    cnt = 0;
    while (cnt < 8) {                  /* Goto the beginning of the file extension                          */
        entry++;
        cnt++;
    }
    cnt = 0;
    while (cnt < 3) {                  /* Get 3 charecters from there                                       */
        *ext_ptr = *entry;
        ext_ptr++;
        entry++;
        cnt++;
    }
    *ext_ptr = 0;
    ext_ptr--;
    while (*ext_ptr == ' ') {          /* If any spaces exist after the file extension, replace them with 0 */
        *ext_ptr = 0;
        ext_ptr--;
    }
#endif


For FAT_GetFreeEntry() (I think 0 is a valid entry for an available FAT):
        while (buf < (FATBuffer + FAT_BootSec.BytsPerSec)) {
            ent_type = FAT_ChkEntType(buf);
#ifdef MBCHG
            if (ent_type == FREE_ENTRY || ent_type == LAST_ENTRY) {
#else
            if (ent_type == FREE_ENTRY) {
#endif
                entry->EntrySec       = sec_num;
                entry->EntrySecOffset = buf - FATBuffer;
                return (OK);
            }
#ifdef MBCHG
            buf +=32;
#else
            if (ent_type == LAST_ENTRY) {
                return (ERR_ROOT_DIR_FULL);
            } else {
                buf += 32;
            }
#endif
        }


For FAT_PutSFN() (This fixed problems with file names such as FILE1234.TXT):
#ifdef MBCHG
    for (idx = 0; idx < 11; idx++)
    {
    FATBuffer[entry->EntrySecOffset + idx] = 0x20;
    }
    for (idx = 0; idx < 8 && *ent_name_given && *ent_name_given != '.'; idx++)
    {
    FATBuffer[entry->EntrySecOffset + idx] = *ent_name_given++;
    }
    if (*ent_name_given == '.')
    {
    ent_name_given++;
        for (idx = 8; idx < 11 && *ent_name_given; idx++)
        {
        FATBuffer[entry->EntrySecOffset + idx] = *ent_name_given++;
        }
    }
    idx = 11;
#else
                                           /* Read the sector from root directory containing the free entry */
    for (idx = 0; idx < 8; idx++) {        /* Fill the first eight charecters of the entry with file name   */
        if (*ent_name_given == '.') {
            while (idx < 8) {
                FATBuffer[entry->EntrySecOffset + idx] = 0x20;
                idx++;
            }
            ent_name_given++;
        } else {
            FATBuffer[entry->EntrySecOffset + idx] = *ent_name_given;
            ent_name_given++;
        }
    }

    for (idx = 8; idx < 11; idx++) {                      /* Fill the next 3 charecters with file extension */
        if (*ent_name_given == '.') {
            while (idx < 11) {
                FATBuffer[entry->EntrySecOffset + idx] = 0x20;
                idx++;
            }
        } else {
            FATBuffer[entry->EntrySecOffset + idx] = *ent_name_given;
            ent_name_given++;
        }
    }
#endif

Mike
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 23 08:45:07 MST 2011

Quote:

...are there tweaks to the code that need to be done because I am not using the development board or is it still a hardware issue?

No, this sample is doing (here) exactly what you described:


Quote:

"If the user calls Main_Copy(), the host sample copies data from file "FILENAME_R" to file "FILENAME_W"."

Also it's printing a lot of messages via UART0 :)

Quote:
Initializing Host Stack
Host Initialized
Connect a Mass Storage device
Mass Storage device connected
Copying from MSREAD.TXT to MSWRITE.TXT...
Copy completed

0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tybls on Thu Jun 23 08:24:34 MST 2011
OK, I believe I have it set up right. I am using a second USB for the 5V with 27 ohm resistors on the USB flash drive connection.

http://imageshack.us/photo/my-images/834/photo0044mr.jpg/

http://imageshack.us/photo/my-images/37/photo0045lq.jpg/

(sorry for fuzzy pictures my phone is old and pixels are low, if a better image is needed I can get them)

The USBHostLite example without any modifications calls Main_Copy();(comment says /* Call the application) in the main function which the abstract states

"If the user calls Main_Copy(), the host sample copies data from file "FILENAME_R" to file "FILENAME_W"."

I have two text files on the flash drive named

"MSREAD.TXT"
"MSWRITE.TXT"

which in the USBHost_main.h file are defined

#define  FILENAME_R  "MSREAD.TXT"
#define  FILENAME_W  "MSWRITE.TXT"

The data from MSREAD.TXT is not being copied to MSWRITE.TXT...

are there tweaks to the code that need to be done because I am not using the development board or is it still a hardware issue?
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 23 07:13:27 MST 2011
I'm using 33 Ohm instead of 27 Ohm and stealing 5V from LPC-Link C69  :eek:

http://www.embeddedartists.com/products/lpcxpresso/LPCXpressoLPC1769revB.pdf
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tybls on Thu Jun 23 06:42:46 MST 2011
So you have a two 27 ohm resistors in series with D- and D+ with 15k resistors grounding D+ and D-? How are you powering your board which in turn powers your flash drive? Thanks again.
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 23 06:19:39 MST 2011
1. No, you are using SWD debugger :)

2. Picture above shows a LPCXpresso1769 working with sample above :):)

3. RDB1768 schematic shows how to connect LPC1769 to USB host connector :eek:
0 项奖励
回复

4,769 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tybls on Thu Jun 23 06:11:56 MST 2011
I do not have a development board(RDP1768). I am using the LPC1769 LPCXpresso board with NXP's ARM Cortex-M3 microcontroller with a JTAG debugger. http://www.embeddedartists.com/products/lpcxpresso/lpc1769_xpr.php. Just trying to figure out if the USBHostLite example will work without a development board.

Edit:

Sorry posted without reading the rest of your post. I'll go ahead and give it a shot and will post later. Thanks for your help.
0 项奖励
回复