cancel
Showing results for 
Search instead for 
Did you mean: 

Why makes HAL_IWDG_Refresh(&hiwdg); USBD_CDC not work?

BKlan
Associate

Hello everyone,

I'm using a stm32f767ZI - Nucleo board, and tries to print with through the USB by using the code generated from stm32cubemx. But i also want the IWDG to reset the controller in case of an error, and to use FreeRTOS.

I the code runs with just FreeRTOS and IWDG, but no USB. It also works with FreeRTOS. USB and IWDG, but without refreshing the IWDG counter (but then the IWDG resets the system after a while).

I can't seem to find any solution to this problem, or any reason resetting the IWDG counter should limit USB to work.

Does anyone got any idea of how i am to move forward?

Notes:

I'm only interested to use the USB in Device - CDC mode.

Here is some code:

void Task1(void const * argument)

{

 /* USER CODE BEGIN StartSyncNodes */

UNUSED(argument);

/* Infinite loop */

for (;;) {

osDelay(1000);

HAL_IWDG_Refresh(&hiwdg);

}

 /* USER CODE END StartSyncNodes */

}

void StartDefaultTask(void const * argument) {

/* init code for USB_DEVICE */

MX_USB_DEVICE_Init();

/* USER CODE BEGIN 5 */

UNUSED(argument);

uint8_t buff[100], len;

uint32_t i = 0;

uint8_t res;

/* Infinite loop */

for (;;) {

len = sprintf((char *) buff, "Test USB%" PRIu32 "\n\r", i++);

res = CDC_Transmit_FS(buff, len);

len = sprintf((char *) buff, "Test huart3 %" PRIu32 " %u\n\r", i, res);

HAL_UART_Transmit(&huart3, (uint8_t *) buff, len, 100000);

osDelay(100);

}

/* USER CODE END 5 */

}

0 REPLIES 0