Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Doubts about LPC1758 USB Host usage

Skip to first unread message

Sink0

unread,
Feb 2, 2012, 4:00:08 PM2/2/12
to
Hi, i need to implement a system that will save some log information on a
USB flash. I will be using a LPC1758 with the USB port acting as a HOST
only. Looking at the user manual, at the example schematic there is a
LM3526-L that is basically a switch with overcurrent protection. As i am
not going to connect my system to anything else than a pendrive, should i
use the switch? If not, is there any schematic example? if yes, why?

Second, i am using Code Sourcery compiler. Is there any USB Host stack that
i can use on a GCC compiler? How about a pendrive interface with FAT
example?

Third question, i think the answer is no. Is there any way to update the
LPC firmware using a pendrive. I belive that would be possible if i could
manage to create a bootloader that can act as USB Host, but that is
probably going to consume a LOT of flash. Any way, is that possible.

Finally, i am used to make my projects with microcontrollers acting as a
USB device, and all USB projects i use a ESD protection IC on the USB Line.
Can i use the same IC with the LPC acting as a Host?

Thank you!

---------------------------------------
Posted through http://www.EmbeddedRelated.com

Arlet Ottens

unread,
Feb 3, 2012, 1:36:42 AM2/3/12
to
On 02/02/2012 10:00 PM, Sink0 wrote:
> Hi, i need to implement a system that will save some log information on a
> USB flash. I will be using a LPC1758 with the USB port acting as a HOST
> only. Looking at the user manual, at the example schematic there is a
> LM3526-L that is basically a switch with overcurrent protection. As i am
> not going to connect my system to anything else than a pendrive, should i
> use the switch? If not, is there any schematic example? if yes, why?

The LM3526 is optional. If you don't care about overcurrent protection,
you can just hook up the USB bus to your 5V supply in the way you want.

> Third question, i think the answer is no. Is there any way to update the
> LPC firmware using a pendrive. I belive that would be possible if i could
> manage to create a bootloader that can act as USB Host, but that is
> probably going to consume a LOT of flash. Any way, is that possible.

Yes, you can create a bootloader that does that. I use a similar
approach, using FAT support in a bootloader on the LPC1758 that can read
the firmware from SD card, or boot from TFTP server. The USB host
protocol isn't very complicated if you only need to support a pendrive.
My bootloader is 14kB, so if you take out the IP/UDP/TFTP support, and
put in the USB host code, it will probably be only slightly bigger. Out
of the total 512kB flash, that's very reasonable.

Sink0

unread,
Feb 3, 2012, 12:37:17 PM2/3/12
to

>Yes, you can create a bootloader that does that. I use a similar
>approach, using FAT support in a bootloader on the LPC1758 that can read
>the firmware from SD card, or boot from TFTP server. The USB host
>protocol isn't very complicated if you only need to support a pendrive.
>My bootloader is 14kB, so if you take out the IP/UDP/TFTP support, and
>put in the USB host code, it will probably be only slightly bigger. Out
>of the total 512kB flash, that's very reasonable.
>
>

Thank you very much. Your answers were of great help.

A few more questions. Do you have a simple example schematic for a LPC1758
Host only circuit to read from a pendrive? Just to make sure i am not
missing anything here. Could you point me any example code on how to
implement a USB host at the bootloader with FAT support? On my application
i am using an NXP example to read and wirite to a pendrive with FAT16
support. I am afraid i will have to go for FAT32 as i will need files
larger than 64k.

Thank you again for your help!

Arlet Ottens

unread,
Feb 3, 2012, 3:22:53 PM2/3/12
to
> A few more questions. Do you have a simple example schematic for a LPC1758
> Host only circuit to read from a pendrive? Just to make sure i am not
> missing anything here. Could you point me any example code on how to
> implement a USB host at the bootloader with FAT support? On my application
> i am using an NXP example to read and wirite to a pendrive with FAT16
> support. I am afraid i will have to go for FAT32 as i will need files
> larger than 64k.

I've used the schematic from Fig.36 from the LPC17xx User Manual, using
the 33R/15k resistors on D+/D-. I left the USB_PWRD, USB_OVRCR and
USB_PPWR unconnected, and I powered the USB client through a separate
5V. It depends on your application how you want to do the power, but for
a fixed pendrive, you might hook it up straight to your 5V supply. You
can add switches or fuses if you need them, but that's up to you.

I don't know of any example code. I think NXP has some app notes, but
I'm not sure how good they are. I wrote my own bootloader.

FAT16 can access files up to 4GB, by the way, not 64k.

Arlet Ottens

unread,
Feb 3, 2012, 3:27:38 PM2/3/12
to

> A few more questions. Do you have a simple example schematic for a LPC1758
> Host only circuit to read from a pendrive? Just to make sure i am not
> missing anything here. Could you point me any example code on how to
> implement a USB host at the bootloader with FAT support? On my application
> i am using an NXP example to read and wirite to a pendrive with FAT16
> support. I am afraid i will have to go for FAT32 as i will need files
> larger than 64k.

Also note that you'll need an external crystal, and that the PLL1 is
quite restricted. I think you can only use a 12 or 16 MHz crystal. Read
the manual carefully.

hamilton

unread,
Feb 3, 2012, 3:58:04 PM2/3/12
to
File size vs partition size

FAT16 partition size at 2 GB for sector size 512


The maximum possible size for a file on a FAT32 volume is 4 GB minus 1 byte

http://en.wikipedia.org/wiki/File_Allocation_Table

hamilton

unread,
Feb 3, 2012, 4:03:08 PM2/3/12
to

Arlet Ottens

unread,
Feb 3, 2012, 4:51:56 PM2/3/12
to
So, FAT16 has maximum file size of 65524 clusters of 32 kB = almost 2
GB, and not 4GB.

Still a lot more than 64kB.

Sink0

unread,
Feb 3, 2012, 5:26:51 PM2/3/12
to

>Also note that you'll need an external crystal, and that the PLL1 is
>quite restricted. I think you can only use a 12 or 16 MHz crystal. Read
>the manual carefully.
>

Thank you. You really helped a lot. That helps a lot for now.

Yea, i will be using a 12Mhz crystal here. It is the standard on most dev
kits.

Cya

Sink0

unread,
Feb 5, 2012, 9:46:16 PM2/5/12
to

>I've used the schematic from Fig.36 from the LPC17xx User Manual, using
>the 33R/15k resistors on D+/D-. I left the USB_PWRD, USB_OVRCR and
>USB_PPWR unconnected, and I powered the USB client through a separate
>5V. It depends on your application how you want to do the power, but for
>a fixed pendrive, you might hook it up straight to your 5V supply. You
>can add switches or fuses if you need them, but that's up to you.
>
>I don't know of any example code. I think NXP has some app notes, but
>I'm not sure how good they are. I wrote my own bootloader.
>
>FAT16 can access files up to 4GB, by the way, not 64k.
>
>

Hi again, one additional doubt. Did you connect USB_UP_LED and VBUS pins?
Let me see if i understand correctly, USB_UP_LED is just used for signaling
purpuses so is not really crytical. And VBUS is just used for devicemode to
scheck when it gets connected sensing VBUS right? So no need at host mode.

Thank you!

Arlet Ottens

unread,
Feb 6, 2012, 1:59:43 AM2/6/12
to

> Hi again, one additional doubt. Did you connect USB_UP_LED and VBUS pins?
> Let me see if i understand correctly, USB_UP_LED is just used for signaling
> purpuses so is not really crytical. And VBUS is just used for devicemode to
> scheck when it gets connected sensing VBUS right? So no need at host mode.

I did attach USB_UP_LED to a LED. The LED is turned on when the USB host
is enabled, but you might as well leave it or, or use the pin as a GPIO
and control a LED yourself.

I left the VBUS pin unconnected.
0 new messages