FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [August 2012 Threads] nxpUSBLib issuesPosted 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 issuesPosted 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 issuesPosted 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 issuesPosted 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 issuesPosted 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 issuesPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|