LPC11U68 & USB CDC: why doesn't it send a message until it recevies one?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

LPC11U68 & USB CDC: why doesn't it send a message until it recevies one?

跳至解决方案
1,129 次查看
chrispflieger
Contributor IV

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?

标签 (3)
0 项奖励
1 解答
1,104 次查看
chrispflieger
Contributor IV

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.

在原帖中查看解决方案

0 项奖励
2 回复数
1,116 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

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

0 项奖励
1,105 次查看
chrispflieger
Contributor IV

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.

0 项奖励