Simple GPIO LED usage.

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

cross mob
Anonymous
Not applicable

Have got the BCM920737TAG board. Am looking to very simply turn on the LED that's connected to P14/P38. Anyone got any quick tips how to initialise the pin then turn the LED on or off?

Really simple code I'm looking for, nothing to do with BTLE stack really.

Cheers!

0 Likes
1 Solution

I believe the following is correct:

// The following will drive P14 low, and if the LED is hooked up right, it will turn on

gpio_configurePin(14/16, 14%16, GPIO_OUTPUT_ENABLE, 0);

I believe that the /16 and Modulus operator are being used to map the Port and the physical pin.

Ex.

P0 – P15 = PORT0

P16-P31 = PORT1

P32-P38 = PORT2

View solution in original post

0 Likes
3 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

We admittedly do not do a very good job of documenting how to enable these types of simple functions.

However, I think this one has been discussed in detail here and vsesto provided some sample code that you will find helpful.

Re: How to turn on LED

0 Likes
Anonymous
Not applicable

thanks for the response

so to conclude: if you want to turn an LED on (where the LED is grounded via the attached GPIO) you call the following:

gpio_configurePin(n/16, n%16, GPIO_OUTPUT_ENABLE, 0);


Where "n" is the number in "Pn" e.g. n=14 when P14?

0 Likes

I believe the following is correct:

// The following will drive P14 low, and if the LED is hooked up right, it will turn on

gpio_configurePin(14/16, 14%16, GPIO_OUTPUT_ENABLE, 0);

I believe that the /16 and Modulus operator are being used to map the Port and the physical pin.

Ex.

P0 – P15 = PORT0

P16-P31 = PORT1

P32-P38 = PORT2

0 Likes