Quality RTOS & Embedded Software

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




Loading

Problems using lwIP and USB host together

Posted by cremonese on August 1, 2014

Hi all, I'm trying to use lwIP and USB host together (LPC1768). The IP is from FreeRTOS sample CORTEXLPC168GCC_RedSuite, and the USB is from the lpcopen 2.10. Each task works fine if alone, but when they work together, I have problems on the enumerating devices when the USB is detached and reattached: sometimes I get an HardFault and sometimes the enumeration hangs in the function:

static HCDSTATUS WaitForTransferComplete(uint8t EdIdx) { while ( HcdED(EdIdx)->status == HCDSTATUSTRANSFERQUEUED ) {} return (HCDSTATUS) HcdED(EdIdx)->status; }

where the status> should be updated by the USB's ISR. It seems an interrupt problem, but I don't understand more.

Any help is greatly appreciated. Best regards, Paolo


Problems using lwIP and USB host together

Posted by rtel on August 1, 2014

Parts of the USB protocol have tight timing requirements, and it might be that the USB interrupt is being pre-empted by the lwIP interrupt. Try ensuring the USB interrupt has a much higher priority than the Ethernet interrupt. If the USB interrupt is not using the FreeRTOS API then you can even set it to the highest possible priority (which is zero on an LPC1768) to ensure its timing is not effected at all by anything else that is happening in the system - not even any critical sections that might be in the lwIP code.

Remember that if the USB interrupt is using the [interrupt safe] FreeRTOS API [only API functions that end in 'FromISR' are intended for use in interrupt] then its priority must be at or below that set by configMAXSYSCALLINTERRUPT_PRIORITY: http://www.freertos.org/RTOS-Cortex-M3-M4.html - if you are using a recent version of FreeRTOS then ensuring configASSERT is defined will check this automatically for you at run time http://www.freertos.org/a00110.html#configASSERT

Also make sure, if using the API in the interrupt, that you make use of the pxHigherPriorityTaskWoken parameter to ensure the interrupt returns directly to any unblocked tasks.

Regards.


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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