EmbDev.net

Forum: ARM programming with GCC/GNU tools LPC2148 USB


von Thomas F. (thomas_f)


Rate this post
useful
not useful
Hello ,

I have just made a LPC2148 board. It connects to the Philips utility and
shows up properly.
Is there any similar quick way to check the USB functionality of the
LPC2148? Or is there any hex file or any other ideas ?

Cheers
Thomas

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
> Is there any similar quick way to check the USB functionality of the
> LPC2148? Or is there any hex file or any other ideas ?

http://www.olimex.com/dev/soft/arm/LPC/LPC2148_USB.zip

von Thomas F. (thomas_f)


Rate this post
useful
not useful
Martin Thomas wrote:
>> Is there any similar quick way to check the USB functionality of the
>> LPC2148? Or is there any hex file or any other ideas ?
>
> http://www.olimex.com/dev/soft/arm/LPC/LPC2148_USB.zip

Hi Martin Thomas,

The files seem to be for IAR. Do you know any WinARM (USB) project I can
compile ?
Else,I would have to port to WinARM.I am trying to avoid that for time
being.

Regards
Thomas

von Thomas F. (thomas_f)


Rate this post
useful
not useful
Thomas Fernando wrote:
> Martin Thomas wrote:
>>> Is there any similar quick way to check the USB functionality of the
>>> LPC2148? Or is there any hex file or any other ideas ?
>>
>> http://www.olimex.com/dev/soft/arm/LPC/LPC2148_USB.zip

I loaded the hex file , and the board comes up as a HID compliant mouse.
So I guess the hardware is functioning OK.
Will try porting to WinARM shortly.

von Thomas F. (thomas_f)


Rate this post
useful
not useful
Hello ,
Is there any documentation available on what each optimization level
does ?
Specifically when trying some code for the LPC2148,I found that when I
compile with optimization level =s,the code compiles,but does not
run,viz. Windows shows it as an unknown USB device.
When I turn off optimization ,level = 0 ; the code works as expected and
shows up as a proper COM port.
TIA

Thomas Fernando wrote
> Thomas Fernando wrote:
>> Martin Thomas wrote:
>>>> Is there any similar quick way to check the USB functionality of the
>>>> LPC2148? Or is there any hex file or any other ideas ?
>>>
>>> http://www.olimex.com/dev/soft/arm/LPC/LPC2148_USB.zip
>
> I loaded the hex file , and the board comes up as a HID compliant mouse.
> So I guess the hardware is functioning OK.
> Will try porting to WinARM shortly.

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
Thomas Fernando wrote:
> Hello ,
> Is there any documentation available on what each optimization level
> does ?
http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Optimize-Options.html#Optimize-Options

> Specifically when trying some code for the LPC2148,I found that when I
> compile with optimization level =s,the code compiles,but does not
> run,viz. Windows shows it as an unknown USB device.
> When I turn off optimization ,level = 0 ; the code works as expected and
> shows up as a proper COM port.
> TIA
The usual suspects when a code is working without optimization but does
not work with optimization are missing volatiles.
(1) Check your code for variables which are modified inside
interrupt-service-routines (ISR) and in the "main-loop", verify these
variables are declared with volatile
(2) Check for delay-loops like for (i=0;i<MAX_COUNT;i++) {;}. Make sure
the counter is declared with volatile
Also verify that read/write to variables which are changed in ISRs are
read/written "atomically" in the main-loop.

edit: first with->without

von Thomas F. (thomas_f)


Rate this post
useful
not useful
Hi Martin,
Thanks for the reply.
Actually I have narrowed down the problem just a little.
I have a small program which reads from the LPC USB and echoes back to
the terminal which emulates this as a COM port.
without optimization as I said the code works just fine.
With optimization if I comment out the getchar part , the code works
fine and shows up as a COM port.
//(In fifo.h)

typedef struct {
    int  head;
    int tail;
    U8  jammed;
    U8  ep;
    U8  status;
    U8  *buf;
} fifo_t;

//(in main.c)
static fifo_t rxfifo;
int VCOM_getchar(void)
{
  U8 c;
 (commented out to check)
/*    if (!fifo_avail(&rxfifo) && fifo_jammed(&rxfifo)) {
        unsigned irq = disableIRQ( );
        fifo_unjam(&rxfifo);
        BulkOut(rxfifo.ep, rxfifo.status);
        restoreIRQ( irq );
    }
*/

  return (fifo_get(&rxfifo, &c) ? c : EOF);
}

//(in fifo.c)
BOOL fifo_get(fifo_t *fifo,U8 *pc)
{
 int next;
 // check if FIFO has data
 if (fifo->head == fifo->tail)
   return FALSE;

 next = (fifo->tail + 1) % VCOM_FIFO_SIZE;
 *pc = fifo->buf[fifo->tail];
  fifo->tail = next;
  return TRUE;
}

The only shared variable with the interrupt here is "rxfifo" which was
declared as volatile , with no changes.

2) unsigned irq = disableIRQ( ); Is this a valid C variable viz.
"unsigned irq"? What does it imply ?

Thomas

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
Thomas Fernando wrote:

sorry, can not tell much about 1) without seeing all of the code and
doing some tests here. Is your code based on Bertrik

> 2) unsigned irq = disableIRQ( ); Is this a valid C variable viz.
> "unsigned irq"? What does it imply ?
Implicit unsigned int (with ARM compilers unsigned long, implicit
unsigned long int), see
http://en.wikipedia.org/wiki/C_syntax#Integral_types

von Thomas F. (thomas_f)


Rate this post
useful
not useful
Martin Thomas wrote:
> sorry, can not tell much about 1) without seeing all of the code and
> doing some tests here. Is your code based on Bertrik

Yes its based on Bertrik's code,which was modified by Dave Madden.I made
some minor modifications.Its mainly for trying out my LPC2148 board.It
can be downloaded from :
http://tech.groups.yahoo.com/group/lpc2000/files/LPC2148/
tftest.rar
Hope you could check,your time permitting.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.