Problem with USB driver and FreeRTOS

paulgcoleman wrote on Tuesday, March 06, 2012:

II’m developing an app for the Atmel UC3C1512 using their AVR Studio 5 development environment and also their software framework (ver 2.5.1-17860.53) and I have an interaction problem between their USB stack and the FreeRTOS scheduler.

Basically, the problem is that when I enable the scheduler the USB starts sending out spurious characters anywhere between 1 and 15 seconds apart. If I don’t enable the scheduler it works as expected. It makes no difference whether I create a task for the sceduler to run it still does it and I’m not using any other features of FreeRTOS i.e. I’m not creating any message queues or semaphores etc.

This is my test code…

#include <FreeRTOS.h>
#include <task.h>
#include <semphr.h>
#include <asf.h>

void USBRxNotifyCallback(void)
{
int charIn;

while(udi_cdc_is_rx_ready())
{
charIn = udi_cdc_getc();
udi_cdc_putc(charIn);
}
}

bool USBEnabledCallback(void)
{
return true;
}

void USBVbusCallback(bool b_vbus_high)
{
if (b_vbus_high)
{
udc_attach();
}
else
{
udc_detach();
}
}

int main(void)
{
pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);

udc_start();

if (!udc_include_vbus_monitoring())
{
udc_attach();
}

// !!! with the following line enabled the USB will send spurious characters out !!!
vTaskStartScheduler();

for(;;);
}

Has anybody else experienced problems with the USB at all?

Thanks, Paul.

rtel wrote on Tuesday, March 06, 2012:

I know nothing about this driver - but how does it interface to the hardware? Is it using any interrupts or system calls other than the single USB peripheral interrupt?

Have you tried initialising the peripheral after the scheduler has started? Take care not to start the device with the scheduler in an inconsistent state.

Regards.

paulgcoleman wrote on Tuesday, March 06, 2012:

Thanks for the reply.

I can’t answer the question off the top of my head as it’s a large framework written by Atmel that I have very little knowledge about.

I had tried initialising the USB after the scheduler has started but it made no difference. I’d trimmed the app down to try and eliminate things and that was what I ended up with.

I will continue to investigate but I just wanted to see if anybody else had had similar issues.

Regards, Paul.