I have a function which responds when the USB of my device is attached.
void usb_attach_cb(void) { printf("usb_attach_cb\n"); ActionDispatcher *actionDispatcher = ActionDispatcher::Instance(); uint8_t data = 1; actionDispatcher->dispatch(ActionType_UsbStatusChange, &data, 1); }
This code works fine but if I add a printf statement to the dispath function that is called I get a stack overflow
vApplicationStackOverflowHook USBC
Is there a way to increase the stack size to avoid this issue?
Device:

Hi alarner,
It is not recommended to call the printf function inside to a callback function. The best practice for this is to create a task and when the usb_attach_cb is triggered, the task with the printf should be triggered. Otherwise, you should increase the number of bytes (stack_size) which will be allocated to the stack of the task that you are using.
Thanks, PM_Dialog
Thank you for the reply. Where might I find a code example that demonstrates increasing the number of bytes allocated to the stack?
Hi alarner,
You could check any of our BLE examples of the SDK. For example, please check the pxp_reporter example and in the main.f you will find “PXP Reporter” task. So, that you have to do is to change the number of bytes to allocate to the stack of the task from the OS_TASK_CREATE() API.
Thanks, PM_Dialog