Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

LPC2146 Keil Mass Storage Example

LPC2146 Keil Mass Storage Example

2005-12-01 by mark_dell555

Hi, I compiled the Keil Mass Storage example for the LPC2146 (just
changed the compiler settings to LPC2146), however when I try to run
it on my LPC2146 board, it sees the mass storage device fine, and can
read from it, however it cant write anything to it (XP stalls).

Anyways I wasnt sure what the problem, and went on to putting togather
my own bulk transfer protocol, and now I'm having another problem
where BulkOut interrupt fires fine, but BulkIn interrupt doesnt fire
at all, and my device reads timeout (using libusb-win32).

So I'm wondering if the two problems are related?  Has anyone else had
similar problems with the keil usb stack?  Any help is, as always,
greatly appriciated.


Cheers,
Mark

Re: LPC2146 Keil Mass Storage Example

2005-12-01 by goudoevr

--- In lpc2000@yahoogroups.com, "mark_dell555" <mark_dell555@y...> 
wrote:
>
> Hi, I compiled the Keil Mass Storage example for the LPC2146 (just
> changed the compiler settings to LPC2146), however when I try to run
> it on my LPC2146 board, it sees the mass storage device fine, and 
can
> read from it, however it cant write anything to it (XP stalls).
> 
> Anyways I wasnt sure what the problem, and went on to putting 
togather
> my own bulk transfer protocol, and now I'm having another problem
> where BulkOut interrupt fires fine, but BulkIn interrupt doesnt fire
> at all, and my device reads timeout (using libusb-win32).
> 
> So I'm wondering if the two problems are related?  Has anyone else 
had
> similar problems with the keil usb stack?  Any help is, as always,
> greatly appriciated.
> 
> 
> Cheers,
> Mark
>

Hi mark

I had the same problem with my own bulk-in transfer intially, but it 
was solved after I made sure there was always a filled Bulk-In 
endpoint. So you should fill the endpoint even before the host 
requests for data. You only get an interrupt to fill the bulk-in 
endpoint after a successful transaction. 

Jeroen

Re: LPC2146 Keil Mass Storage Example

2005-12-01 by mark_dell555

--- In lpc2000@yahoogroups.com, "goudoevr" <goudoevr@x...> wrote:
>
> --- In lpc2000@yahoogroups.com, "mark_dell555" <mark_dell555@y...> 
> wrote:
> >
> > Hi, I compiled the Keil Mass Storage example for the LPC2146 (just
> > changed the compiler settings to LPC2146), however when I try to run
> > it on my LPC2146 board, it sees the mass storage device fine, and 
> can
> > read from it, however it cant write anything to it (XP stalls).
> > 
> > Anyways I wasnt sure what the problem, and went on to putting 
> togather
> > my own bulk transfer protocol, and now I'm having another problem
> > where BulkOut interrupt fires fine, but BulkIn interrupt doesnt fire
> > at all, and my device reads timeout (using libusb-win32).
> > 
> > So I'm wondering if the two problems are related?  Has anyone else 
> had
> > similar problems with the keil usb stack?  Any help is, as always,
> > greatly appriciated.
> > 
> > 
> > Cheers,
> > Mark
> >
> 
> Hi mark
> 
> I had the same problem with my own bulk-in transfer intially, but it 
> was solved after I made sure there was always a filled Bulk-In 
> endpoint. So you should fill the endpoint even before the host 
> requests for data. You only get an interrupt to fill the bulk-in 
> endpoint after a successful transaction. 
> 
> Jeroen
>

Hrmm according to the LPC214x User Manual, if the Bulk-In endpoint is
empty, it should send a NAK back to the host, and then generate the
Bulk-In interrupt.  But I'll try doing what you suggest.

Thanks,
Mark

"For data transfer from an endpoint to the host, the host will send an
IN token to that endpoint. If the FIFO corresponding to the endpoint
is empty, the device will return a NAK and will raise an interrupt to
the system. On this interrupt the CPU fills a packet of data in the
endpoint FIFO.The next IN token that comes after filling this packet
will transfer this packet to the host." -- LPC214x User Manual

Re: LPC2146 Keil Mass Storage Example

2005-12-01 by mark_dell555

Thanks for the help, just figured it out.  You need to use
CMD_SET_MODE, to tell it to generate interrupts on Bulk In NAK.  Check
out pg224, of the LPC214x User Manual.  I changed my USB_Configure()
procedure to the following:

void USB_Configure (BOOL cfg) {

  WrCmdDat(CMD_CFG_DEV, DAT_WR_BYTE(cfg ? CONF_DVICE : 0));
  WrCmdDat(CMD_SET_MODE, DAT_WR_BYTE(INAK_BI));

  REALIZE_EP = 0x00000003;
  while ((DEV_INT_STAT & EP_RLZED_INT) == 0);
  DEV_INT_CLR = EP_RLZED_INT;
}

Basically just adding the 2nd line, and that did it.  Now I can go to
sleep  :)

Cheers,
Mark

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.