cancel
Showing results for 
Search instead for 
Did you mean: 

need help about usb device of stm32f105

404658589
Associate II
Posted on December 24, 2009 at 03:23

need help about usb device of stm32f105

3 REPLIES 3
404658589
Associate II
Posted on May 17, 2011 at 13:35

hi,

i have trouble with STM32F105'USB .I change the latest Mass_Storage example provided in STM32_USB-FS-Device_Lib_V3.1.0 to implement the data send and receive.now,OUT is OK.when host output data ,then stm32 can receive them without error.But when host computer read the device,stm32 have no response and did not execute. it seems that IN endpoint is disabled.but i have traced the related registers.IN endpoint is alredy enabled.in STM32F103x,IN point is set as EP_TX_VALID,then host read command can easily make stm32 response with interrupt.

// STM32F103x Initialize Endpoint 1

_SetEPType(ENDP1, EP_BULK);

_Clear_Status_Out(ENDP1);

UserToPMABufferCopyENDP1(USB_TX_DATA,1); //主机第一次会读走这�?�信�?�

_SetEPTxCount(ENDP1, 1);

_SetEPTxAddr(ENDP1, ENDP1_TXADDR);

_SetEPRxStatus(ENDP1, EP_RX_DIS);

_SetEPTxStatus(ENDP1, EP_TX_VALID);

So,who can tell me how to set related registers of STM32 Connectivity Line to make the device response the the host read command like STM32F103x.

any replies will be appreciated.

thanks in advance.

[ This message was edited by: 404658589 on 23-12-2009 01:14 ]

chikos33
Associate II
Posted on May 17, 2011 at 13:35

I'm not sure I correctly understood what you want to do,

- Are you sure you are preparing the data to be send through the endpoint (using the function ''USB_SIL_Write(EP1_IN, uint8_t * pbuffer, uint32_t wlength);'' ?

- If you did, this should automatically activate the endpoint, and it will respond when the host will ask for data. but make sure it is done before the host sends IN tokens.

- You could also try using the status forcing after the previous function, but I'm not sure this is the right way to do (just a workarround I guess):

''SetEPTxStatus(ENDP1, EP_TX_VALID);''

-->

USB_SIL_Write(EP1_IN, uint8_t * pbuffer, uint32_t wlength);

SetEPTxStatus(EP1_IN, EP_TX_VALID);

- There is also a ''radical'' way to make endpoint respond: by resetting it using the following function each time it sends data:

/* Init EP1 IN as Bulk endpoint */

OTG_DEV_EP_Init(EP1_IN, OTG_DEV_EP_TYPE_BULK, BULK_MAX_PACKET_SIZE);

I hope this could help you, this new library is really complicated compared to the STM32F103x one. :o

404658589
Associate II
Posted on May 17, 2011 at 13:35

first,thank chikos33 very much.

now, new condition occured.

- host OUT a data

- STM32 receive it

- then use USB_SIL_Write(...) to write data to TxFIFO

- finally,host execute IN command,the data can be read right.

- then STM32 USB will catch a IN interrupt.in this interrupt ISR,use

USB_SIL_Write(...) to write data to TxFIFO again

- in this condition,host can read data from device at any time correctly.

I am sure that host OUT command is OK.

if host uses OUT to send data several times, then host can not use IN command to read data from device(stm32 have no interrupt response),but data from host received correctly.