EmbDev.net

Forum: ARM programming with GCC/GNU tools LPC2148 USB


Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 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

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 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

Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 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

Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 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.

Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 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.

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 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/Optimi...

> 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

Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 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

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 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

Author: Thomas Fernando (thomas_f)
Posted on:

Rate this post
0 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.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.