Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


nxpUSBLib issues

Posted by David Thedens on August 23, 2012
I have nxpUSBLib working on a LPCExpresso LPC1769. I modified the generic HID example for my VID/PID and descriptors.
The device enumerates using this framework
I want to use an RTOS and I have a thread that replaces the for(;;) loop. This thread runs every 10ms and it is running.

The issue is that the device does not work at all. The USB reset causes the Host to send GetDescriptor but the stack does not ACK

I am seeing an interrupt upon connection, but the device just does not send anything.
So I an wondering what could be the difference between the standard CMSIS startup and the one provide by FreeRTOS?

RE: nxpUSBLib issues

Posted by Richard on August 23, 2012
Before we get into how you have integrated the USB - do you have FreeRTOS running on your hardware stand alone? That is, can you run the standard demo, or create a couple of tasks that just increment variables and see that both tasks are executing?


RE: nxpUSBLib issues

Posted by David Thedens on August 24, 2012
I create the project using the built in wizard in LPCExpresso 4.2.3
the example has tow threads and was working fine, so the LPC1769 is working fine with FreeRTOS.

I did find some problems in the USB stack. One is the port.pin for the revB board is 2.9 and that fixed the pull up issue.
I also found that the HID endpoint descriptor must be FIXED_CONTROL_ENDPOINT_SIZE which is 64. I ported the descriptors from another project it the device only had a 32 byte endpoint 0.

I also found a hardcoded #define __REDLIB so I changed the build to include these

The nxpUSBLib has a very weird build structure.

so now, the stack is now partially enumerating a HID device with my descriptors.
sometimes it will fully enumerate.

the thread is simple
xTaskCreate( vUserTask1, ( signed portCHAR * ) "Task1", USERTASK_STACK_SIZE, NULL, 3, NULL );
stack size is 512
void vUserTask1(void *pvParameters)
while (1) {

since neither of these functions call any RTOS API I should not have to worry about ISR/RTOS issues, correct?

#define configUSE_PREEMPTION1
#define configUSE_IDLE_HOOK0
#define configMAX_PRIORITIES( ( unsigned portBASE_TYPE ) 5 )
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ( ( unsigned long ) 119000000 )
#define configTICK_RATE_HZ( ( portTickType ) 1000 )
#define configMINIMAL_STACK_SIZE( ( unsigned short ) 512 )
#define configTOTAL_HEAP_SIZE( ( size_t ) ( 9 * 1024 ) )
#define configMAX_TASK_NAME_LEN( 12 )
#define configUSE_TRACE_FACILITY1
#define configUSE_16_BIT_TICKS0
#define configIDLE_SHOULD_YIELD0
#define configUSE_CO_ROUTINES 0
#define configUSE_MUTEXES1

#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )

#define configUSE_ALTERNATIVE_API 0
#define configQUEUE_REGISTRY_SIZE10

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

#define INCLUDE_vTaskPrioritySet1
#define INCLUDE_uxTaskPriorityGet1
#define INCLUDE_vTaskDelete1
#define INCLUDE_vTaskCleanUpResources0
#define INCLUDE_vTaskSuspend1
#define INCLUDE_vTaskDelayUntil1
#define INCLUDE_vTaskDelay1
#define INCLUDE_uxTaskGetStackHighWaterMark1

RE: nxpUSBLib issues

Posted by David Thedens on August 24, 2012
I'll have to check to see that this part is running at the right clock speed and that the ticks are correct.
It is either that, or nxpUSBLib is telling fibs. I change the thread vTaskDelay(1) and it starts to enumerate ok.
the doc says that these callback functions can be called at 30-50ms for USB Device.

RE: nxpUSBLib issues

Posted by David Thedens on August 24, 2012
interesting update.
The doc says that the the calls

can be called every 30ms. Doesn't seem to be the case.
I was calling every 10ms but the device fails to enumerate. I change to 5ms and found that it gets farther into the enumeration
changed it to 1ms and it enumerates fine.

All the provided code examples user a super loop so I am wondring if this should be explained in the nxpUSBLib doc if someone wants to use a RTOS.

Since my device enumerates with 10ms polling rate, I can set the wait time to 1ms for enumeration, and then back it off to 10ms for normal operation.

RE: nxpUSBLib issues

Posted by Richard on August 24, 2012
USB has very strict timing requirements during the enumeration process, and less strict after that. It might be best to raise the priority of the task and use short delays (or use an interrupt) to enumerate, then lower the priority and use longer delays after that.

You might also consider using vTaskDelayUntil() in place of vTaskDelay() to get less jitter in your timing.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner