EmbeddedRelated.com
Forums

Olimex lpc2478 stk: USB initialization code

Started by Todorovic Dragan October 20, 2009
Hello,

i am trying to initialize USB device block on the Olimex lpc2478 board. i was looking into NXP lpc24xx documentation as well as lpcusb and keil usb code examples but still have no luck. board is booted through u-boot originaly prepared by Olimex (USB host block activated).

having look into the NXP docs i am trying to initialize USB port 2 to behave as USB device. also, http://www.olimex.com/dev/images/ARM/LPC/LPC2478-STK-sch.gif is the schematics where i can see pins role:

U2D+ : p0.31/USB_D+2
U2D- : USB_D-2
soft connect (USB1_CONNECT) : p1.19/.../cap1[1]
up led (USB_UP_LED1) : p1.18/USB_UP_LED1/...
Vbus (VBUS) : p0.14/...

because the input Vbus signal isn't connected to lpc2478 VBUS pin (p1.30) i am choosing GPIO function as to make lpc internally put HIGH on USB device VBUS:

PINSEL3 &= ~(3 << 28); // activate p1.30

next, output up led and soft connect signals. i've checked C/SC jumper: it is properly set on SC position. here is the configuration:

// p1.18 usb up led 1
PINSEL3 &= ~(3 << 4);
IODIR1 |= (1L << 18);
IOSET1 = (1L << 18);

and for soft connect signal,

PINSEL3 &= ~(0x03 << 6); // P1.19
PINMODE3 = (PINMODE3 & ~(0x03 << 6)) | (0x02 << 6); // is this OK??
IODIR1 |= (1L << 19); // output
IOSET1 = (1L << 19); // 'not connected state' (look into C/SC jumper)

i plan to activate connect signal at the end of initialization code so that because pin is set HIGH. i am not sure if PINMODE3 is to be set or not: i've tried all combinations but non of them works. finally, D+ line:

// p0.31 usb D+ 2
PINSEL1 = (PINSEL1 & ~(3 << 30)) | (1 << 30);

rest of the code is enabling usb block, device controler clocs, USB port configuration (0x03: port 1 host, port 2 device), endpoint realization and slave mode config, interrupt registers cleanup, mode initialization and device interrupt enabling (EP_SLOW and DEV_STAT). device address has been set to 0 and is enabled. i then install interrupt handler and activate soft connect signal:

IOCLR1 = (1L << 19);

what i expect is that an enumeration OUT packet should trigger USB interrupt but that never happens. my ISR code is never called..

to test if interrupt is propagated, some time after the soft connect pin is made LOW i initiate EP_SLOW event directly from code: interrupt is generated and my ISR code executed...

do i properly configure lpc pins regarding to Olimex schematix and lpc2478 docs? all the code examples that i found doesn't include OTG: is there anything special i should initialize for OTG controller? does USB host block which is previously configured by u-boot makes a problem?

i am willing to provide complete initialization code i use if necessary...
regards,
dragan

An Engineer's Guide to the LPC2100 Series

P1.30 has to be configured as VBUS in order to have
USB device working. You can't configure it as a GPIO pin
and pull it up hoping the USB block will recognize it
as VBUS.

regards,
Tom

--- In l..., Todorovic Dragan wrote:
>
> Hello,
>
> i am trying to initialize USB device block on the Olimex lpc2478 board. i was looking into NXP lpc24xx documentation as well as lpcusb and keil usb code examples but still have no luck. board is booted through u-boot originaly prepared by Olimex (USB host block activated).
>
> having look into the NXP docs i am trying to initialize USB port 2 to behave as USB device. also, http://www.olimex.com/dev/images/ARM/LPC/LPC2478-STK-sch.gif is the schematics where i can see pins role:
>
> U2D+ : p0.31/USB_D+2
> U2D- : USB_D-2
> soft connect (USB1_CONNECT) : p1.19/.../cap1[1]
> up led (USB_UP_LED1) : p1.18/USB_UP_LED1/...
> Vbus (VBUS) : p0.14/...
>
> because the input Vbus signal isn't connected to lpc2478 VBUS pin (p1.30) i am choosing GPIO function as to make lpc internally put HIGH on USB device VBUS:
>
> PINSEL3 &= ~(3 << 28); // activate p1.30
>
> next, output up led and soft connect signals. i've checked C/SC jumper: it is properly set on SC position. here is the configuration:
>
> // p1.18 usb up led 1
> PINSEL3 &= ~(3 << 4);
> IODIR1 |= (1L << 18);
> IOSET1 = (1L << 18);
>
> and for soft connect signal,
>
> PINSEL3 &= ~(0x03 << 6); // P1.19
> PINMODE3 = (PINMODE3 & ~(0x03 << 6)) | (0x02 << 6); // is this OK??
> IODIR1 |= (1L << 19); // output
> IOSET1 = (1L << 19); // 'not connected state' (look into C/SC jumper)
>
> i plan to activate connect signal at the end of initialization code so that because pin is set HIGH. i am not sure if PINMODE3 is to be set or not: i've tried all combinations but non of them works. finally, D+ line:
>
> // p0.31 usb D+ 2
> PINSEL1 = (PINSEL1 & ~(3 << 30)) | (1 << 30);
>
> rest of the code is enabling usb block, device controler clocs, USB port configuration (0x03: port 1 host, port 2 device), endpoint realization and slave mode config, interrupt registers cleanup, mode initialization and device interrupt enabling (EP_SLOW and DEV_STAT). device address has been set to 0 and is enabled. i then install interrupt handler and activate soft connect signal:
>
> IOCLR1 = (1L << 19);
>
> what i expect is that an enumeration OUT packet should trigger USB interrupt but that never happens. my ISR code is never called..
>
> to test if interrupt is propagated, some time after the soft connect pin is made LOW i initiate EP_SLOW event directly from code: interrupt is generated and my ISR code executed...
>
> do i properly configure lpc pins regarding to Olimex schematix and lpc2478 docs? all the code examples that i found doesn't include OTG: is there anything special i should initialize for OTG controller? does USB host block which is previously configured by u-boot makes a problem?
>
> i am willing to provide complete initialization code i use if necessary...
> regards,
> dragan
>

The Olimex board configures USB ports as one for host, another for device.
It seems to follow to this figure on the manual,

http://www.standardics.nxp.com/support/documents/microcontrollers/pdf/user.manual.lpc24xx.pdf
Fig 56. USB OTG port configuration: port U1 host, port U2 device (p400)

But some pin connections swap in Port U1 and U2

On the Manual
Host
USB_UP_LED1 P1.18
USB_D+1 P0.29
USB_D-1 P0.30
USB_PWRD1 P1.22
USB_OVRCR1 P1.27
USB_PPWR1 P1.19

Device
USB_UP_LED2 P0.13
USB_CONNECT2 P0.14
USB_D+2 P0.31
USB_D-2 USB_D-2
VBUS P1.30

On the Olimex schematic
Host
USB_UP_LED1 P1.18
U1D+ P0.29
U1D- P0.30
USB_PWRD2 P1.30 <---
#USB_OVRCR2 P1.31 <---
#USB_PPWR2 P0.12 <---

Device
USB_UP_LED2 P1.13
USB1_CONNECT P1.19 <---
U2D+ P0.31
U2D- USB_D-2
VBUS P0.14 <---

I recommend you to contact to Olimex, and confirm the schematic is correct one.

Tsuneo

--- In l..., Todorovic Dragan wrote:
>
> Hello,
>
> i am trying to initialize USB device block on the Olimex lpc2478 board. i was looking into NXP lpc24xx documentation as well as lpcusb and keil usb code examples but still have no luck. board is booted through u-boot originaly prepared by Olimex (USB host block activated).
>
> having look into the NXP docs i am trying to initialize USB port 2 to behave as USB device. also, http://www.olimex.com/dev/images/ARM/LPC/LPC2478-STK-sch.gif is the schematics where i can see pins role:
>
> U2D+ : p0.31/USB_D+2
> U2D- : USB_D-2
> soft connect (USB1_CONNECT) : p1.19/.../cap1[1]
> up led (USB_UP_LED1) : p1.18/USB_UP_LED1/...
> Vbus (VBUS) : p0.14/...
>
> because the input Vbus signal isn't connected to lpc2478 VBUS pin (p1.30) i am choosing GPIO function as to make lpc internally put HIGH on USB device VBUS:
>
> PINSEL3 &= ~(3 << 28); // activate p1.30
>
> next, output up led and soft connect signals. i've checked C/SC jumper: it is properly set on SC position. here is the configuration:
>
> // p1.18 usb up led 1
> PINSEL3 &= ~(3 << 4);
> IODIR1 |= (1L << 18);
> IOSET1 = (1L << 18);
>
> and for soft connect signal,
>
> PINSEL3 &= ~(0x03 << 6); // P1.19
> PINMODE3 = (PINMODE3 & ~(0x03 << 6)) | (0x02 << 6); // is this OK??
> IODIR1 |= (1L << 19); // output
> IOSET1 = (1L << 19); // 'not connected state' (look into C/SC jumper)
>
> i plan to activate connect signal at the end of initialization code so that because pin is set HIGH. i am not sure if PINMODE3 is to be set or not: i've tried all combinations but non of them works. finally, D+ line:
>
> // p0.31 usb D+ 2
> PINSEL1 = (PINSEL1 & ~(3 << 30)) | (1 << 30);
>
> rest of the code is enabling usb block, device controler clocs, USB port configuration (0x03: port 1 host, port 2 device), endpoint realization and slave mode config, interrupt registers cleanup, mode initialization and device interrupt enabling (EP_SLOW and DEV_STAT). device address has been set to 0 and is enabled. i then install interrupt handler and activate soft connect signal:
>
> IOCLR1 = (1L << 19);
>
> what i expect is that an enumeration OUT packet should trigger USB interrupt but that never happens. my ISR code is never called..
>
> to test if interrupt is propagated, some time after the soft connect pin is made LOW i initiate EP_SLOW event directly from code: interrupt is generated and my ISR code executed...
>
> do i properly configure lpc pins regarding to Olimex schematix and lpc2478 docs? all the code examples that i found doesn't include OTG: is there anything special i should initialize for OTG controller? does USB host block which is previously configured by u-boot makes a problem?
>
> i am willing to provide complete initialization code i use if necessary...
> regards,
> dragan
>

Hi Tom,

--- In l..., "Dezheng" wrote:
>
> P1.30 has to be configured as VBUS in order to have
> USB device working. You can't configure it as a GPIO pin
> and pull it up hoping the USB block will recognize it
> as VBUS.
>
> regards,
> Tom

i configured p1.30 as you told. i've also configured U13::#ENA input (#USB_PPWR2) as GPIO output:

// p0.12, #USB_PPWR2
PINSEL0 &= ~(3L << 24);
IODIR0 |= (1L << 12);
IOCLR0 = (1L << 12);

and reconfigured p1.30 to be VBUS:

// p1.30, VBUS
PINSEL3 &= ~(3L << 28);
PINSEL3 |= (2L << 28);
PINMODE3 = (PINMODE3 & ~(3L << 28));
IODIR1 &= ~(1L << 30);

also, i've put this:

// configure P0.14 for Vbus sense, GPIO input
PINSEL0 &= ~(3L << 28);
IODIR0 &= ~(1L << 14);
PINMODE0 = (PINMODE0 & ~(3L << 28)) | (2L << 28);
but still, interrupt routine isn't called...

just a few notes more.. . after the initialization code finishes i can see on my linux box message logs that it sees new device but is unable to set its address. also, i've added code that switches soft connect output (p1.19) LOW/HIGH on every x seconds: this also works as linux starts address sequence every time p1.19 goes LOW. also, i was disconnecting cable from the pc too: Vbus sense reads HIGH/LOW depending on cable 'state'.. everything seems to be good... on read, D+2 gives me LOW..

then, during the 'switch soft connect' endless loop i tried to connect USB flash stick into Olimex's USB port 1 (host): i get DEV_STAT interrupt where device status is CON, SUS and SUS_CH HIGH. also, D+2 goes HIGH...

i of course suspect now on the rest of mt initialization code, ep realization, etc. but, that code is taken from existing code examples... will contact Olimex too as Tsuneo suggested...
any ideas?
regards,
dragan

>
> --- In l..., Todorovic Dragan wrote:
> >
> > Hello,
> >
> > i am trying to initialize USB device block on the Olimex lpc2478 board. i was looking into NXP lpc24xx documentation as well as lpcusb and keil usb code examples but still have no luck. board is booted through u-boot originaly prepared by Olimex (USB host block activated).
> >
> > having look into the NXP docs i am trying to initialize USB port 2 to behave as USB device. also, http://www.olimex.com/dev/images/ARM/LPC/LPC2478-STK-sch.gif is the schematics where i can see pins role:
> >
> > U2D+ : p0.31/USB_D+2
> > U2D- : USB_D-2
> > soft connect (USB1_CONNECT) : p1.19/.../cap1[1]
> > up led (USB_UP_LED1) : p1.18/USB_UP_LED1/...
> > Vbus (VBUS) : p0.14/...
> >
> > because the input Vbus signal isn't connected to lpc2478 VBUS pin (p1.30) i am choosing GPIO function as to make lpc internally put HIGH on USB device VBUS:
> >
> > PINSEL3 &= ~(3 << 28); // activate p1.30
> >
> > next, output up led and soft connect signals. i've checked C/SC jumper: it is properly set on SC position. here is the configuration:
> >
> > // p1.18 usb up led 1
> > PINSEL3 &= ~(3 << 4);
> > IODIR1 |= (1L << 18);
> > IOSET1 = (1L << 18);
> >
> > and for soft connect signal,
> >
> > PINSEL3 &= ~(0x03 << 6); // P1.19
> > PINMODE3 = (PINMODE3 & ~(0x03 << 6)) | (0x02 << 6); // is this OK??
> > IODIR1 |= (1L << 19); // output
> > IOSET1 = (1L << 19); // 'not connected state' (look into C/SC jumper)
> >
> > i plan to activate connect signal at the end of initialization code so that because pin is set HIGH. i am not sure if PINMODE3 is to be set or not: i've tried all combinations but non of them works. finally, D+ line:
> >
> > // p0.31 usb D+ 2
> > PINSEL1 = (PINSEL1 & ~(3 << 30)) | (1 << 30);
> >
> > rest of the code is enabling usb block, device controler clocs, USB port configuration (0x03: port 1 host, port 2 device), endpoint realization and slave mode config, interrupt registers cleanup, mode initialization and device interrupt enabling (EP_SLOW and DEV_STAT). device address has been set to 0 and is enabled. i then install interrupt handler and activate soft connect signal:
> >
> > IOCLR1 = (1L << 19);
> >
> > what i expect is that an enumeration OUT packet should trigger USB interrupt but that never happens. my ISR code is never called..
> >
> > to test if interrupt is propagated, some time after the soft connect pin is made LOW i initiate EP_SLOW event directly from code: interrupt is generated and my ISR code executed...
> >
> > do i properly configure lpc pins regarding to Olimex schematix and lpc2478 docs? all the code examples that i found doesn't include OTG: is there anything special i should initialize for OTG controller? does USB host block which is previously configured by u-boot makes a problem?
> >
> > i am willing to provide complete initialization code i use if necessary...
> >
> >
> > regards,
> > dragan
>

Olimex offers two different schematics for LPC-2378STK on its web page,
http://www.olimex.com/dev/lpc-2378stk.html

Under DOCUMENTS,
http://www.olimex.com/dev/pdf/LPC2378-STK.pdf
- Just USB device connection, no host

Under HARDWARE,
http://www.olimex.com/dev/images/LPC2378-STK-sch.gif
- Host and device, you pointed this one at your first post

As I said in my post, the schematic under HARDWARE seems a wrong one for USB port connection. On the board pictures of the web page, no USB host connector appears.

Olimex may have updated the board in secret...
Which schematic does your board matches to?

Tsuneo

--- In l..., "t_chinzei" wrote:
> The Olimex board configures USB ports as one for host, another for device.
> It seems to follow to this figure on the manual,
>
> http://www.standardics.nxp.com/support/documents/microcontrollers/pdf/user.manual.lpc24xx.pdf
> Fig 56. USB OTG port configuration: port U1 host, port U2 device (p400)
>
> But some pin connections swap in Port U1 and U2
>
> On the Manual
> Host
> USB_UP_LED1 P1.18
> USB_D+1 P0.29
> USB_D-1 P0.30
> USB_PWRD1 P1.22
> USB_OVRCR1 P1.27
> USB_PPWR1 P1.19
>
> Device
> USB_UP_LED2 P0.13
> USB_CONNECT2 P0.14
> USB_D+2 P0.31
> USB_D-2 USB_D-2
> VBUS P1.30
>
> On the Olimex schematic
> Host
> USB_UP_LED1 P1.18
> U1D+ P0.29
> U1D- P0.30
> USB_PWRD2 P1.30 <---
> #USB_OVRCR2 P1.31 <---
> #USB_PPWR2 P0.12 <---
>
> Device
> USB_UP_LED2 P1.13
> USB1_CONNECT P1.19 <---
> U2D+ P0.31
> U2D- USB_D-2
> VBUS P0.14 <---
>
> I recommend you to contact to Olimex, and confirm the schematic is correct one.
>
> Tsuneo
>
> --- In l..., Todorovic Dragan wrote:
> >
> > Hello,
> >
> > i am trying to initialize USB device block on the Olimex lpc2478 board. i was looking into NXP lpc24xx documentation as well as lpcusb and keil usb code examples but still have no luck. board is booted through u-boot originaly prepared by Olimex (USB host block activated).
> >
> > having look into the NXP docs i am trying to initialize USB port 2 to behave as USB device. also, http://www.olimex.com/dev/images/ARM/LPC/LPC2478-STK-sch.gif is the schematics where i can see pins role:
> >
> > U2D+ : p0.31/USB_D+2
> > U2D- : USB_D-2
> > soft connect (USB1_CONNECT) : p1.19/.../cap1[1]
> > up led (USB_UP_LED1) : p1.18/USB_UP_LED1/...
> > Vbus (VBUS) : p0.14/...
> >
> > because the input Vbus signal isn't connected to lpc2478 VBUS pin (p1.30) i am choosing GPIO function as to make lpc internally put HIGH on USB device VBUS:
> >
> > PINSEL3 &= ~(3 << 28); // activate p1.30
> >
> > next, output up led and soft connect signals. i've checked C/SC jumper: it is properly set on SC position. here is the configuration:
> >
> > // p1.18 usb up led 1
> > PINSEL3 &= ~(3 << 4);
> > IODIR1 |= (1L << 18);
> > IOSET1 = (1L << 18);
> >
> > and for soft connect signal,
> >
> > PINSEL3 &= ~(0x03 << 6); // P1.19
> > PINMODE3 = (PINMODE3 & ~(0x03 << 6)) | (0x02 << 6); // is this OK??
> > IODIR1 |= (1L << 19); // output
> > IOSET1 = (1L << 19); // 'not connected state' (look into C/SC jumper)
> >
> > i plan to activate connect signal at the end of initialization code so that because pin is set HIGH. i am not sure if PINMODE3 is to be set or not: i've tried all combinations but non of them works. finally, D+ line:
> >
> > // p0.31 usb D+ 2
> > PINSEL1 = (PINSEL1 & ~(3 << 30)) | (1 << 30);
> >
> > rest of the code is enabling usb block, device controler clocs, USB port configuration (0x03: port 1 host, port 2 device), endpoint realization and slave mode config, interrupt registers cleanup, mode initialization and device interrupt enabling (EP_SLOW and DEV_STAT). device address has been set to 0 and is enabled. i then install interrupt handler and activate soft connect signal:
> >
> > IOCLR1 = (1L << 19);
> >
> > what i expect is that an enumeration OUT packet should trigger USB interrupt but that never happens. my ISR code is never called..
> >
> > to test if interrupt is propagated, some time after the soft connect pin is made LOW i initiate EP_SLOW event directly from code: interrupt is generated and my ISR code executed...
> >
> > do i properly configure lpc pins regarding to Olimex schematix and lpc2478 docs? all the code examples that i found doesn't include OTG: is there anything special i should initialize for OTG controller? does USB host block which is previously configured by u-boot makes a problem?
> >
> > i am willing to provide complete initialization code i use if necessary...
> >
> >
> > regards,
> > dragan
>

Auu sorry, I mistakenly referred to LPC2378-STK page in my last post.

But on Olimex LPC2478-STK page, similar error is found, too.
http://www.olimex.com/dev/lpc-2478stk.html

This page also has two different schematics,

DOCUMENTS:
http://www.olimex.com/dev/pdf/ARM/LPC/LPC-2478STK.pdf
U1 - device, U2 - host, pin connections around USB are fine

HARDWARE:
http://www.olimex.com/dev/images/ARM/LPC/LPC2478-STK-sch.gif
U1 - host, U2 - device, pin connections are wrong.

Tsuneo

--- In l..., "t_chinzei" wrote:
>
> Olimex offers two different schematics for LPC-2378STK on its web page,
> http://www.olimex.com/dev/lpc-2378stk.html
>
> Under DOCUMENTS,
> http://www.olimex.com/dev/pdf/LPC2378-STK.pdf
> - Just USB device connection, no host
>
> Under HARDWARE,
> http://www.olimex.com/dev/images/LPC2378-STK-sch.gif
> - Host and device, you pointed this one at your first post
>
> As I said in my post, the schematic under HARDWARE seems a wrong one for USB port connection. On the board pictures of the web page, no USB host connector appears.
>
> Olimex may have updated the board in secret...
> Which schematic does your board matches to?
>
> Tsuneo
>
> --- In l..., "t_chinzei" wrote:
> >
> >
> >
> >
> > The Olimex board configures USB ports as one for host, another for device.
> > It seems to follow to this figure on the manual,
> >
> > http://www.standardics.nxp.com/support/documents/microcontrollers/pdf/user.manual.lpc24xx.pdf
> > Fig 56. USB OTG port configuration: port U1 host, port U2 device (p400)
> >
> > But some pin connections swap in Port U1 and U2
> >
> > On the Manual
> > Host
> > USB_UP_LED1 P1.18
> > USB_D+1 P0.29
> > USB_D-1 P0.30
> > USB_PWRD1 P1.22
> > USB_OVRCR1 P1.27
> > USB_PPWR1 P1.19
> >
> > Device
> > USB_UP_LED2 P0.13
> > USB_CONNECT2 P0.14
> > USB_D+2 P0.31
> > USB_D-2 USB_D-2
> > VBUS P1.30
> >
> > On the Olimex schematic
> > Host
> > USB_UP_LED1 P1.18
> > U1D+ P0.29
> > U1D- P0.30
> > USB_PWRD2 P1.30 <---
> > #USB_OVRCR2 P1.31 <---
> > #USB_PPWR2 P0.12 <---
> >
> > Device
> > USB_UP_LED2 P1.13
> > USB1_CONNECT P1.19 <---
> > U2D+ P0.31
> > U2D- USB_D-2
> > VBUS P0.14 <---
> >
> > I recommend you to contact to Olimex, and confirm the schematic is correct one.
> >
> > Tsuneo
> >
> > --- In l..., Todorovic Dragan wrote:
> > >
> > > Hello,
> > >
> > > i am trying to initialize USB device block on the Olimex lpc2478 board. i was looking into NXP lpc24xx documentation as well as lpcusb and keil usb code examples but still have no luck. board is booted through u-boot originaly prepared by Olimex (USB host block activated).
> > >
> > > having look into the NXP docs i am trying to initialize USB port 2 to behave as USB device. also, http://www.olimex.com/dev/images/ARM/LPC/LPC2478-STK-sch.gif is the schematics where i can see pins role:
> > >
> > > U2D+ : p0.31/USB_D+2
> > > U2D- : USB_D-2
> > > soft connect (USB1_CONNECT) : p1.19/.../cap1[1]
> > > up led (USB_UP_LED1) : p1.18/USB_UP_LED1/...
> > > Vbus (VBUS) : p0.14/...
> > >
> > > because the input Vbus signal isn't connected to lpc2478 VBUS pin (p1.30) i am choosing GPIO function as to make lpc internally put HIGH on USB device VBUS:
> > >
> > > PINSEL3 &= ~(3 << 28); // activate p1.30
> > >
> > > next, output up led and soft connect signals. i've checked C/SC jumper: it is properly set on SC position. here is the configuration:
> > >
> > > // p1.18 usb up led 1
> > > PINSEL3 &= ~(3 << 4);
> > > IODIR1 |= (1L << 18);
> > > IOSET1 = (1L << 18);
> > >
> > > and for soft connect signal,
> > >
> > > PINSEL3 &= ~(0x03 << 6); // P1.19
> > > PINMODE3 = (PINMODE3 & ~(0x03 << 6)) | (0x02 << 6); // is this OK??
> > > IODIR1 |= (1L << 19); // output
> > > IOSET1 = (1L << 19); // 'not connected state' (look into C/SC jumper)
> > >
> > > i plan to activate connect signal at the end of initialization code so that because pin is set HIGH. i am not sure if PINMODE3 is to be set or not: i've tried all combinations but non of them works. finally, D+ line:
> > >
> > > // p0.31 usb D+ 2
> > > PINSEL1 = (PINSEL1 & ~(3 << 30)) | (1 << 30);
> > >
> > > rest of the code is enabling usb block, device controler clocs, USB port configuration (0x03: port 1 host, port 2 device), endpoint realization and slave mode config, interrupt registers cleanup, mode initialization and device interrupt enabling (EP_SLOW and DEV_STAT). device address has been set to 0 and is enabled. i then install interrupt handler and activate soft connect signal:
> > >
> > > IOCLR1 = (1L << 19);
> > >
> > > what i expect is that an enumeration OUT packet should trigger USB interrupt but that never happens. my ISR code is never called..
> > >
> > > to test if interrupt is propagated, some time after the soft connect pin is made LOW i initiate EP_SLOW event directly from code: interrupt is generated and my ISR code executed...
> > >
> > > do i properly configure lpc pins regarding to Olimex schematix and lpc2478 docs? all the code examples that i found doesn't include OTG: is there anything special i should initialize for OTG controller? does USB host block which is previously configured by u-boot makes a problem?
> > >
> > > i am willing to provide complete initialization code i use if necessary...
> > >
> > >
> > > regards,
> > > dragan
> > >
>

--- In l..., "t_chinzei" wrote:
>
> Auu sorry, I mistakenly referred to LPC2378-STK page in my last post.
>
> But on Olimex LPC2478-STK page, similar error is found, too.
> http://www.olimex.com/dev/lpc-2478stk.html
>
> This page also has two different schematics,
>
> DOCUMENTS:
> http://www.olimex.com/dev/pdf/ARM/LPC/LPC-2478STK.pdf
> U1 - device, U2 - host, pin connections around USB are fine
>
> HARDWARE:
> http://www.olimex.com/dev/images/ARM/LPC/LPC2478-STK-sch.gif
> U1 - host, U2 - device, pin connections are wrong.
>
> Tsuneo
>

heh... you are right Tsuneo, http://www.olimex.com/dev/pdf/ARM/LPC/LPC-2478STK.pdf contains valid schematics. lpcusb example code/library works now. many thanx !

just in case someone has the same problem, here is the working initialization code:

// enable usb block
PCONP |= (1 << 31);

// enable device controller clocks
OTG_CLK_CTRL = 0x1b;
while ((OTG_CLK_STAT & 0x1b) == 0);

// p1.19 for CONNECT.. this is't USB_CONNECT hw pin so manage it on your own
PINSEL3 &= ~(3L << 6);
PINMODE3 = (PINMODE3 & ~(3L << 6)) | (2L << 6);
IODIR1 |= (1L << 19); // output
IOSET1 = (1L << 19); // not connected state (look into C/SC jumper)

// p0.12, #USB_PPWR2
PINSEL0 &= ~(3L << 24); // GPIO, output
//PINSEL0 |= (1L << 24);
IODIR0 |= (1L << 12);
IOCLR0 = (1L << 12);

// configure P0.14 for Vbus sense, GPIO input
PINSEL0 &= ~(3L << 28);
IODIR0 &= ~(1L << 14);
PINMODE0 = (PINMODE0 & ~(3L << 28)) | (2L << 28);

// p1.30, VBUS
PINSEL3 &= ~(3L << 28);
PINSEL3 |= (2L << 28);
PINMODE3 = (PINMODE3 & ~(3L << 28)); // | (3L << 28);
IODIR1 &= ~(1L << 30);

// p0.29 usb D+ 1
PINSEL1 &= ~(3L << 26);
PINSEL1 |= (1L << 26);

// p0.30 usb D- 1
PINSEL1 &= ~(3L << 28);
PINSEL1 |= (1L << 28);

// p1.18 usb up led 1
PINSEL3 &= ~(3L << 4);
PINSEL3 |= (1L << 4);

// select desired USB port pins: port 1
OTG_STAT_CTRL = 0;
OTG_CLK_CTRL &= ~(1 << 3);

/**
rest of the code: EP realization, mode setup, address setup,
interrupt initialization...
*/
...
..
regards,
dragan