Mbed-os: REALTEK_RTL8195AM GPIO slow

Created on 3 Jan 2018  路  5Comments  路  Source: ARMmbed/mbed-os

Description

  • Type: Enhancement
  • Priority: Major

Enhancement

Target
REALTEK_RTL8195AM

Toolchain:
GCC_ARM

Toolchain version:
7.2.1 20170904

mbed-cli version:
1.2.2

mbed-os sha:
2b4ff78ab Merge pull request #5738 from ARMmbed/release-candidate

Description
Toggling gpio on this platform is slow. It taks ~7us to toggle a pin. where as on platform such as k64f the pin toggle time is around 300ns which is 20x faster.

Slow GPIO makes bit banging impossible. this driver https://os.mbed.com/users/bridadan/code/WS2812/ wouldn't work for example.

Steps to reproduce
This code prints out how much time it takes to toggle a pin:

#include "mbed.h"
#include "gpio_api.h"

#define GPIO_LED_PIN            PE_0

int main()
{
    gpio_t gpio_led;
    gpio_init(&gpio_led, GPIO_LED_PIN);
    gpio_dir(&gpio_led, PIN_OUTPUT);    // Direction: Output
    gpio_mode(&gpio_led, PullNone);     // No pull

    uint32_t num_of_loops = 10000;
    printf("start\r\n");

    for (uint8_t k = 0;  k < 255; k++)
    {
        us_ticker_init();
        __disable_irq();
        start = us_ticker_read();
        for (uint32_t i=0; i<num_of_loops; i++)
        {
            gpio_write(&gpio_led, 1);
            for(j=0; j<k; j++) __NOP();
            gpio_write(&gpio_led, 0);
            for(j=0; j<k; j++) __NOP();
        }
        end = us_ticker_read();
        __enable_irq();
        uint32_t ns_per_loop = (end-start)*1000/num_of_loops/2;
        printf("k = %u: %u ns per loop\r\n", k, ns_per_loop);

        if (ns_per_loop > 1000) break;
    }
closed_in_jira realtek mirrored bug

All 5 comments

@ARMmbed/team-realtek

Hi, @LiyouZhou
The GPIO toggling time is around 600ns. For the fix for this issue, please refer to #6326 .

Fantastic, I look forward to tring it out. Thank you for the fix.

I believe this issue has already been solved by #6326. Is there any further issue or we can close this issue.

ARM Internal Ref: MBOTRIAGE-298

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbonghi picture rbonghi  路  3Comments

cesarvandevelde picture cesarvandevelde  路  4Comments

chrissnow picture chrissnow  路  4Comments

neilt6 picture neilt6  路  4Comments

davidantaki picture davidantaki  路  3Comments