Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

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?

Regards.

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
__REDLIB__
__USE_CMSIS=CMSISv2p00_LPC17xx
__LPC17XX__
USB_DEVICE_ONLY
DEBUG
__CODE_RED

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)
{
USB_Connect();
while (1) {
HID_Device_USBTask(&My_HID_Interface);
USB_USBTask();
vTaskDelay(10);
}
}

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_COUNTING_SEMAPHORES 0
#define configUSE_ALTERNATIVE_API 0
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_RECURSIVE_MUTEXES1
#define configQUEUE_REGISTRY_SIZE10
#define configGENERATE_RUN_TIME_STATS 0

/* 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
USB_Device_USBTask(...)
USB_USBTask()

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.

Regards.


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists