Turning on LED's

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Turning on LED's

999 Views
GarageDirt
Contributor II
A basic question here, because I am still struggling. On a MIMXRT1176evk there are 2 user led's. In the SDK, there is a program evkmimxrt1170_igpio_led_output_cm7. Running the program turns on the green led with a 1 second cycle time. Where SPECIFICALLY,is the line of code that tells which led is to be turned on? The ConfigTools didn't tell me much. I can see in the Definitions, the words "BOARD_USER_LED_GPIO", and "BOARD_USER_LED_GPIO_PIN". I don't get enlightened very much there either. I think I know that the green led is USER_LED_CTL1 and red led is USER_LED_CTL2, but where in the code would I make a change to turn on the red led instead of the green led? Part B of the question: If instead of turning on leds, I wanted to turn on and off pins on connector J9, for instance, I can see in ConfigTools, where you add "Routed pin/signal". I can add GPIO_AD_04 to that list that refers to J9[8]. No problem there, but now, how do modify the code to make J9[8] toggle? Reading the literature provides no clues.
0 Kudos
5 Replies

987 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @GarageDirt ,

 Every GPIO, you can control it.

  To your mentioned SDK project, about the detail GPIO code, please check the pin_mux.c in the board folder, you can find the GPIO definition:

IOMUXC_SetPinMux(
IOMUXC_GPIO_AD_04_GPIO9_IO03, /* GPIO_AD_04 is configured as GPIO9_IO03 */
0U); /* Software Input On Field: Input Path is determined by functionality */

The board .h also define it:

#ifndef BOARD_USER_LED_GPIO
#define BOARD_USER_LED_GPIO GPIO9
#endif
#ifndef BOARD_USER_LED_GPIO_PIN
#define BOARD_USER_LED_GPIO_PIN (3U)
#endif

This code will configure the detail pins:

GPIO_PinInit(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, &led_config);

So, if you want to change the pin, just add your related GPIO pin in the pinmux, then do the same like the above code.

 

Wish it helps you!

If you still have questions about it, please kindly let me know.

Kerry

0 Kudos

980 Views
GarageDirt
Contributor II

Hi Kerry,    I got your reply but I am not understanding the actual steps needed to control I/O.

I can see in pin_mux.c and board.h, the code you referred to.  It's there.  I don't know how it got there.  To make it easier for me, tell me how to do the following:      

Right now, the green led is flashing.  Let's say I want to add code to make the red led flash at the same time.  What actual lines of code do I add to make this happen?   I mean, the actual things I need to type and where to type them.

0 Kudos

970 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @GarageDirt ,

   Please keep patient, as it is really very simple, I give you the thought, you need to learn it at first.

1. add code to make the red led flash at the same time.

  You need to check the board schematic, check which detail GPIO pin it is connected to your mentioned red led, just like the green led, it also has the GPIO number.

2. Define your red led GPIO pin function the pinmux.c

3. In our main code, initialize the GPIO for your red led.

Please learn it and do it by yourself.

If you still have questions about it, please kindly let me know.

Best Regards,

kerry

0 Kudos

964 Views
GarageDirt
Contributor II

Ok, here is what I did, starting with the igpio_led_cm7 program, and your instructions.

 

  1.   You said, check board schematic and check which pin is connected to the red led.

 

What I did...  Checking schematic I find green led is  pin M13 with label GPIO_AD_04 for the green led and  L14 with label GPIO_AD_26 for the red led.

 

Next, I go to ConfigTools to add the red led to the pins list.  I add GPIO_AD_26 to the list of 7 items that are already there.   I DO NOTE that GPIO_AD_04 for the green led is NOT THERE.   Why not?  The green led flashes when you run the code, it flashes.  Shouldn't it be on the pins list?

 

  1.   You said define your red led GPIO pin function in the pinmux.c

 

What I did.... I go to pin_mux.c and see there are four items in the BOARD_InitPins list.

I do see that GPIO_AD_04 the pin for a green led is there.  So, what I did is type in the following:

 

  IOMUXC_SetPinMux(

      IOMUXC_GPIO_AD_26_GPIO9_IO03, 0U); // code for red led

 

Now, there are 5 items on the list.

 

  1.   You said, In our main code, initialize the GPIO for the red led. 

 

The first line of code after main(void) is:

 

gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};

 

Am I supposed to modify that?  If so, in what way?

 

 

Next, in main(void) I see BOARD_InitPins, when I look inside that, I can see all 5 items on the list, including code for both red and green leds.

 

I don't know what else to do now, so I try Build....

 

I get 3 errors....  too few arguments to function IOMUXC_SetPinMux.  What do I do now... it is exactly the same as the code for the green led.

 

Extreme frustration continues.

0 Kudos

939 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @GarageDirt 

Check my reply in your another post:

https://community.nxp.com/t5/i-MX-RT/Both-LED-s/td-p/1295019

Which I already share my testing project with the MCUXpresso IDE, it works OK.

If you still have issues about it, please kindly let me know.

Kerry

0 Kudos