GPIO output timing

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JeCh_627636
Level 1
Level 1
10 sign-ins 5 replies posted 5 sign-ins

Can anyone help to speed up the GPIO output timing for BCM20737 ?

With the following GPIO function codes below :

// generate SCLK2 High pulse

  gpio_setPinOutput(SCLK2_PIN / 16, SCLK2_PIN % 16, GPIO_PIN_OUTPUT_HIGH);

  // generate SCLK2 Low pulse

  gpio_setPinOutput(SCLK2_PIN / 16, SCLK2_PIN % 16, GPIO_PIN_OUTPUT_LOW);

Measure the SCLK2 high time, and it's about 2.5us.  To control one external driver, the SCLK2 high time needs to be around 0.5us.

Is this possible for BCM20737 (I suppose the internal CPU clock should be fast enough) ? or any suggestion ?

0 Likes
1 Solution
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

There's no faster way to toggle a GPIO. No timer callback will give you anything near 500ns. A clock line is the only thing that can achieve down to the nanosecond level.

The SPI hardware will be able to clock out chunks of 8 bits, but not just 1 bit at a time.

Jacob

View solution in original post

9 Replies
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received
0 Likes

Thanks, but that doesn't help. What I ask is to shorten but not increase the delay. In my case, the pulse rate is about 500K~1MHz.

0 Likes

May I know what is the external component that you are driving? And where did you get the above piece of code?

It's a kind of LED driver with serial data/clock inputs. The piece of code we use (with gpio_setPinOutput and bleapputils_delayUs) is pretty similar to the thread as you said.  Its was working for the old model with slower driver, but not for this new one.  

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

This code will bring out a 2MHz (T = .5us) clock line onto pin 32:

#include "aclk.h"

gpio_configurePin(32 /16, 32 % 16, GPIO_KS_OUTPUT_ENABLE, GPIO_PIN_OUTPUT_HIGH);

aclk_configure(2000000, ACLK0, ACLK_FREQ_24_MHZ);

You can toggle it on and off to try to control your peripheral.

Alternatively, you can route this same clock line through the PWM which is specifically meant for these types of applications. Please see the pwm_tones application in the SDK for example code on using the PWM.

Jacob

  My case is to send out serial data bits one time only (during each change). It's not like PWM with continuous waveform generation. I still hope to know how CPU can handle GPIO control in a fast way.

0 Likes

Is this still an issue?

jensencheng

0 Likes

still an issue, but just take a walk around with different driver.

0 Likes
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

There's no faster way to toggle a GPIO. No timer callback will give you anything near 500ns. A clock line is the only thing that can achieve down to the nanosecond level.

The SPI hardware will be able to clock out chunks of 8 bits, but not just 1 bit at a time.

Jacob