cancel
Showing results for 
Search instead for 
Did you mean: 

Improve bitbang driver speed

martingingras9
Associate II
Posted on November 24, 2014 at 21:06

Hi,

I am using the STM32F2xx cube API to implement a raw bitbang usb driver for the FTDI ft245.  I am currently achieving speed of 5000 bytes/s.  I would like to improve the speed.  The bitbang code is simple as:

<..>

__disable_irq();

// set data pins      

        HAL_GPIO_WritePin(FT_D0_PORT, FT_D0_PIN, (CHECK_BIT(data, 0) == 0) ? GPIO_PIN_RESET : GPIO_PIN_SET);

        HAL_GPIO_WritePin(FT_D1_PORT, FT_D1_PIN, (CHECK_BIT(data, 1) == 0) ? GPIO_PIN_RESET : GPIO_PIN_SET);

        HAL_GPIO_WritePin(FT_D2_PORT, FT_D2_PIN, (CHECK_BIT(data, 2) == 0) ? GPIO_PIN_RESET : GPIO_PIN_SET);

        HAL_GPIO_WritePin(FT_D3_PORT, FT_D3_PIN, (CHECK_BIT(data, 3) == 0) ? GPIO_PIN_RESET : GPIO_PIN_SET);

        HAL_GPIO_WritePin(FT_D4_PORT, FT_D4_PIN, (CHECK_BIT(data, 4) == 0) ? GPIO_PIN_RESET : GPIO_PIN_SET);

        HAL_GPIO_WritePin(FT_D5_PORT, FT_D5_PIN, (CHECK_BIT(data, 5) == 0) ? GPIO_PIN_RESET : GPIO_PIN_SET);

        HAL_GPIO_WritePin(FT_D6_PORT, FT_D6_PIN, (CHECK_BIT(data, 6) == 0) ? GPIO_PIN_RESET : GPIO_PIN_SET);

        HAL_GPIO_WritePin(FT_D7_PORT, FT_D7_PIN, (CHECK_BIT(data, 7) == 0) ? GPIO_PIN_RESET : GPIO_PIN_SET);

__enable_irq();

<...>

The pins are configured as follow:

FT_DX_PORT, FT_DX_PIN, GPIO_MODE_INPUT, GPIO_NOPULL, GPIO_SPEED_HIGH

is there anything I can do or example I could follow or inspire myself? (beside implementing some asm?)

thanx

Mart

#bitband-bit-bang
20 REPLIES 20
martingingras9
Associate II
Posted on December 01, 2014 at 21:15

OK problem solved, thanx for the hint :)

Mart