cancel
Showing results for 
Search instead for 
Did you mean: 

F103 USB BULK OUT Problem

schlenkj
Associate
Posted on May 04, 2014 at 16:04

Hello,

I am trying to get double buffered USB bulk-out transfers working.The device does enumerate correctly but bulk transfers do not even raise interrupts.

This is my EP initialization (usb_prop.c : reset handler:

[code]

    SetBTABLE(BTABLE_ADDRESS);

    // ========================================================

    // Initialize Endpoint 0

    // ========================================================

    SetEPType(ENDP0, EP_CONTROL);

    SetEPTxStatus(ENDP0, EP_TX_NAK);//STALL);

    

    SetEPRxAddr(ENDP0, ENDP0_RXADDR);

    SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);

    

    SetEPTxAddr(ENDP0, ENDP0_TXADDR);

    Clear_Status_Out(ENDP0);

    

    SetEPRxValid(ENDP0);

    

    // ========================================================

    // Initialize Endpoint 1 - tx - IN

    // ========================================================

    SetEPType(ENDP1, EP_BULK);

    SetEPDoubleBuff(ENDP1);

    SetEPDblBuffAddr (ENDP1, ENDP1_BUF0_ADDR, ENDP1_BUF1_ADDR);

    SetEPDblBuffCount(ENDP1, EP_DBUF_IN, 0x40);

    ClearDTOG_RX(ENDP1);

    ClearDTOG_TX(ENDP1);

    ToggleDTOG_TX(ENDP1);

    SetEPTxStatus(ENDP1, EP_TX_NAK);

    SetEPRxStatus(ENDP1, EP_RX_DIS);

    

    // ========================================================

    // Initialize Endpoint 2 - rx - OUT

    // ========================================================

    SetEPType(ENDP2, EP_BULK);

    SetEPDoubleBuff(ENDP2);

    SetEPDblBuffAddr (ENDP2, ENDP2_BUF0_ADDR, ENDP2_BUF1_ADDR);

    SetEPDblBuffCount(ENDP2, EP_DBUF_OUT, 0x40);

    ClearDTOG_RX(ENDP2);

    ClearDTOG_TX(ENDP2);

    ToggleDTOG_RX(ENDP2);

    SetEPRxStatus(ENDP2, EP_RX_VALID);

    SetEPTxStatus(ENDP2, EP_TX_DIS);

    SetEPRxValid(ENDP0);

    SetDeviceAddress(0);

    bDeviceState = ATTACHED;

[/code]

register values:

USB_EP0R = 00005250

USB_EP1R = 00000161

USB_EP2R = 00007102

CNTR     = 0000BF00

ISTR     = 00000000

USB_DADDR= 000000A4

BTAB_ADDR= 00000000

PMA BTABLE:

00000080    ADDR0_TX

00000000    COUNT0_TX

00000040    ADDR0_RX

00008400    COUNT0_RX

00000100    ...

00000040

00000140

00000040

00000180

00008400

000001C0

00008400

Device : STM32F103C8T6
2 REPLIES 2
zzdz2
Associate II
Posted on May 04, 2014 at 17:33

    ClearDTOG_RX(ENDP2);

    ClearDTOG_TX(ENDP2);

    ToggleDTOG_RX(ENDP2);

Have you tried not to set the DTOG_RX ?

Maybe it will work when started with DTOG cleared.

tsuneo
Senior
Posted on May 04, 2014 at 18:49

Assuming you are working on STM32_USB-FS-Device_Lib_V4.0.0,

// ========================================================
// Initialize Endpoint 2 - rx - OUT
// ========================================================
SetEPType(ENDP2, EP_BULK);
SetEPDoubleBuff(ENDP2);
SetEPDblBuffAddr (ENDP2, ENDP2_BUF0_ADDR, ENDP2_BUF1_ADDR);
SetEPDblBuffCount(ENDP2, EP_DBUF_OUT, 0x40);
ClearDTOG_RX(ENDP2);
ClearDTOG_TX(ENDP2);
ToggleDTOG_RX(ENDP2); // <---- ToggleDTOG_TX(ENDP2);
SetEPRxStatus(ENDP2, EP_RX_VALID);
SetEPTxStatus(ENDP2, EP_TX_DIS);

Tsuneo