2020-08-04 11:17 AM
Hello,
I'm using CubeMx to create a project with usb cdc serial port and BLE functionality. CubeMx generates a sequencer UTIL_SEQ_Run(~0); that runs the BLE state machine. In the code below, if I comment out UTIL_SEQ_Run(~0); the code runs fine per Workshop #3 on Youtube. Prints out the data "Hello World" to hyperterminal. As soon as I uncomment UTIL_SEQ_Run(~0); and run the app in the debugger I get a hard fault. Has anyone seen this behavior while trying to run the sequencer with usb cdc? Any thoughts as to how to debug this as far as where I should start looking?
Thanks,
2020-08-04 11:18 AM
Here is the code:
/* Infinite loop */
/* USER CODE BEGIN WHILE */
char usbOut[256];
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
sprintf(usbOut, "Hello World\r\n");
//CDC_Transmit_FS(( uint8_t * )usbOut, strlen( usbOut ));
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, ( uint8_t * )usbOut, strlen( usbOut ));
USBD_CDC_TransmitPacket(&hUsbDeviceFS);
HAL_Delay(1000);
UTIL_SEQ_Run(~0);
}
/* USER CODE END 3 */
2020-08-06 12:32 AM
Yes, I had the same issue. Apparently the BLE stack uses the USB clock for RNG purposes, and the clock can't have shared ressources.
See solution here:
2020-08-06 07:20 AM
2020-08-06 07:44 AM
Oh, yes, it doesn't look the same as the problem I was facing: I did not have a hardfault, but my USB was not working
Also, as far as I know, you're supposed to have only the UTIL_SEQ_Run(~0); in your while loop... If you want to print something (blink test with USB) try to set up a TIM interrupt that starts a new task in the sequencer.
Also, did you implement these 3 interrupts in your _it.c file? They are called by the RF stack.
/**
* @brief This function handles RTC wake-up interrupt through EXTI line 19.
*/
void RTC_WKUP_IRQHandler(void)
{
HW_TS_RTC_Wakeup_Handler();
}
/**
* @brief This function handles IPCC RX occupied interrupt.
*/
void IPCC_C1_RX_IRQHandler(void)
{
HW_IPCC_Rx_Handler();
}
/**
* @brief This function handles IPCC TX free interrupt.
*/
void IPCC_C1_TX_IRQHandler(void)
{
HW_IPCC_Tx_Handler();
}
/* USER CODE END 1 */
2020-08-06 09:52 AM