Currently i am developing a software and i am stuck. I need some help.
I am using stm32f103, hal and library freertos.
I wrote a little serial debugger fucntion that sends chars over uart or usb cdc.
Here is my definetions:
in the header file:
#if ( DEBUG == DEBUG_ENABLE )
/* printf definetion */
#define DEBUG_MSG( FLAG, fmt, ...)
do
{
if( FLAG )
printf( "[%08d]%s:%d:%s(): " fmt "\r\n", HAL_GetTick(), __FILE__, __LINE__, __func__, ##__VA_ARGS__);
}while( 0 );
#else
#define DEBUG_MSG( FLAG, fmt, ... )
#endif
and in the c file:
#define PUTCHAR_PROTOTYE int fputc( int ch, FILE *f )
PUTCHAR_PROTOTYE
{
#if DEBUG_PORT == USB_DEBUG
CDC_Transmit_FS((uint8_t *)&ch, 1);
#elif DEBUG_PORT == UART_DEBUG
HAL_UART_Transmit( pDEBUG_PORT, ( uint8_t * )&ch, 1, 0xFFFF );
#else
#error "Define a debug port!"
#endif
return ch;
}
I am using this like: DEBUG_MSG(MAIN_DEBUG, "Gsm manager thread started!");
When debugger port is uart_debug there is no problem at all. Everything runs perfectly.
But whenever i select usb_debug port, there some thing happing.
While debug port is usb cdc, i am getting some text like below:
"[0[0[0[0[6"
But in the debug mode, in putc function i am putting a break point at CDC_Transmit_FS((uint8_t *)&ch, 1); line, and pressing F5 and i am getting:
[00010046]../Src/main.c:633:gsmmanager_handler(): Gsm manager thread started!
string just like as i expecting. And if i put CDC_Transmit_FS((uint8_t *)"test", strlen("test")); lines right after CDC_Transmit_FS((uint8_t *)&ch, 1); and i am getting:
[0[0test
string.
So i dont understand anything. What could it be?