I'm using the CDC / VCOM example for USB ROM and I modified it a bit to be interrupt driven.
I want to write "hello world" on startup, and I call USBD_API->hw->WriteEP(), but it doesn't show up on the terminal until I type a character on the terminal; it's like it wait for something first. After the first, it seemingly work OK, but it's really odd. Is there something I'm missing?
Solved! Go to Solution.
Yeah, it seems the USB wasn't fully enumerated, or whatever.
Since my code didn't do a connection check, the string just went into a buffer and never came out till it got "bumped" with a new character.
Adding a delay fixed the glitch.
Hi,
Can you use the vcom_write("Hello World!!\r\n", 15);? If is the same as you call the USBD_API->hw->WriteEP(),but the status is checked before it is called.
/* Virtual com port write routine*/
uint32_t vcom_write(uint8_t *pBuf, uint32_t len)
{
VCOM_DATA_T *pVcom = &g_vCOM;
uint32_t ret = 0;
if ( (pVcom->tx_flags & VCOM_TX_CONNECTED) && ((pVcom->tx_flags & VCOM_TX_BUSY) == 0) ) {
pVcom->tx_flags |= VCOM_TX_BUSY;
/* enter critical section */
NVIC_DisableIRQ(USB0_IRQn);
ret = USBD_API->hw->WriteEP(pVcom->hUsb, USB_CDC_IN_EP, pBuf, len);
/* exit critical section */
NVIC_EnableIRQ(USB0_IRQn);
}
return ret;
}
BR
XiangJun Rong
Yeah, it seems the USB wasn't fully enumerated, or whatever.
Since my code didn't do a connection check, the string just went into a buffer and never came out till it got "bumped" with a new character.
Adding a delay fixed the glitch.