USBVC001 with USBLD001 switch to RTOS runs into ExceptionHandler MemManage_Handler

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Tobias_Gerber
Employee
Employee
HI all,

Is there any application sample to run un this configuration (USBVC001 with RTOS)?

If switched to RTOS (USBLD001 check box), Dave change the App Connectivity view and loads some additional apps (RTOS001 for example).
447.attach

Main.c:
....
int main(void)
{
// status_t status; // Declaration of return variable for DAVE3 APIs (toggle comment if required)

/* Initialization of DAVE Apps */
DAVE_Init();

/* Initialization of the USBVC001 App */
USBVC001_Init();

// start RTOS
osKernelStart();
osDelay(osWaitForever);

for (;;);
return 0;
}

in USBVC001_Init(); we get the MemManager exception.

HW: XMC4500 Relax Lite Kit V1
Dave 3.18 build 2013-09-12
USBLD001 - 1.0.12
0 Likes
4 Replies
Not applicable
Hi Tobias,

The "USBVC001_Init()" should be placed inside the thread function since it is used in RTOS environment. Here is an example,

/* Thread declaration */
void USB_Thread (void const *Argument);

int main(void)
{

DAVE_Init();

osThreadId ThreadId1;

/* Thread definition */
osThreadDef(USB_Thread, osPriorityNormal, 1, 0);
/* Thread creation */
ThreadId1 = osThreadCreate(osThread(USB_Thread),NULL);
if (ThreadId1 != NULL)
{
/* Start the OS kernel explicitly.*/
osKernelStart();
}
return 0;
}

void USB_Thread (void const *Argument)
{

USBVC001_Init();

}

Best regards,
Sophia
0 Likes
Tobias_Gerber
Employee
Employee
Hi Sophia,
Thanks for help.

I tried to get your code running - but failing in osKernelStart()
Yes, the thread is created - but I do not reach it.
It seems, that the system fails on a stack overflow in HAL_CM4.s

There is the output:
442.attach

It is close to (HAL_CM4.s)
VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */
MOVEQ R0,#0x01 /* os_tsk->stack_frame val */
MOVNE R0,#0x00
STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */
STMDB R12!,{R4-R11} /* Save Old context */
STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */

PUSH {R2,R3}
BL rt_stk_check /* Check for Stack overflow */
POP {R2,R3}

Still I didn't change any other files than main.c. So I expect the reason in the DAVE framework.
Thanks for help.

BR Tobias
0 Likes
Not applicable
Hi Tobias,

Sorry, I missed out two points:
1) Change the stack size to 2048 in RTOS001 RTX tab;
439.attach
2) Add main USB management task "USB_USBTask()" right after your application tasks (eg. USBVC001_SendString((const char *)"Hello World");)

Attached is an example for your reference.


Best regards,
Sophia
0 Likes
Tobias_Gerber
Employee
Employee
Hi Sophia,

Thanks, solved!

BR Tobias
0 Likes