Getting output at GPIO pin 18 (GPIO5_Io11) in imx8m mini evk

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

Getting output at GPIO pin 18 (GPIO5_Io11) in imx8m mini evk

Jump to solution
1,866 Views
imranhassan
Contributor II

I am trying to get output to blink an LED at GPIO 5 pin 11 (which is physically at pin 18) using the example code but I am not able to get result.

I am using multimeter to check the voltage at the pin 18 with respect to ground which is pin 20. 

here is code


/*
 * Copyright (c) 2015, Freescale Semiconductor, Inc.
 * Copyright 2016-2020 NXP
 * All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "pin_mux.h"
#include "clock_config.h"
#include "board.h"
#include "fsl_debug_console.h"
#include "fsl_gpio.h"
#include "fsl_iomuxc.h" // Include the IOMUXC header if not already included


/*******************************************************************************
 * Definitions
 ******************************************************************************/
#define EXAMPLE_LED_GPIO     GPIO5
#define EXAMPLE_LED_GPIO_PIN 11U

/*******************************************************************************
 * Prototypes
 ******************************************************************************/

/*******************************************************************************
 * Variables
 ******************************************************************************/
/* The PIN status */
volatile bool g_pinSet = false;
/*******************************************************************************
 * Code
 ******************************************************************************/
/*!
 * @brief Main function
 */
int main(void)
{
    /* Define the init structure for the output LED pin*/
    gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};

    /* Board pin, clock, debug console init */
    /* Board specific RDC settings */
    BOARD_RdcInit();

    BOARD_InitBootPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();
    BOARD_InitMemory();

    /* Configure the IOMUXC for GPIO5_IO08 (physical pin 18) */
    IOMUXC_SetPinMux(IOMUXC_ECSPI2_MOSI_GPIO5_IO11, 0U);
    IOMUXC_SetPinConfig(IOMUXC_ECSPI2_MOSI_GPIO5_IO11, 0x10B0u);

        /* Init output LED GPIO. */
    GPIO_PinInit(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, &led_config);

    /* Print a note to terminal. */
    PRINTF("\r\n GPIO Driver example\r\n");
    PRINTF("\r\n The LED is blinking.\r\n");



    while (1)
    {
        SDK_DelayAtLeastUs(300000, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
#if (defined(FSL_FEATURE_IGPIO_HAS_DR_TOGGLE) && (FSL_FEATURE_IGPIO_HAS_DR_TOGGLE == 1))
        GPIO_PortToggle(EXAMPLE_LED_GPIO, 1u << EXAMPLE_LED_GPIO_PIN);
#else
        if (g_pinSet)
        {
            GPIO_PinWrite(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, 0U);
            g_pinSet = false;
        }
        else
        {
            GPIO_PinWrite(EXAMPLE_LED_GPIO, EXAMPLE_LED_GPIO_PIN, 1U);
            g_pinSet = true;
        }
#endif /* FSL_FEATURE_IGPIO_HAS_DR_TOGGLE */
    }
}
0 Kudos
Reply
1 Solution
1,784 Views
imranhassan
Contributor II

Thanks @Chavira for your suggestions and showing the test video.

The main problem was I have not enabled PKE bit that enables internal pull up/down resistor. Second is setting full drive strength and full speed, I was able to get 3.3 volts at PIN number 19 (as corrected by @Chavira ). 

The details of register are as follow

Bits | Field | Value
-----|-------|------
[15] |       | 0
[14] |       | 0
[13] |       | 0
[12] | HYS   | 1

[11] | PUS1  | 1
[10] | PUS0  | 1
[9]  | PUE   | 1
[8]  | PKE   | 1

[7]  | ODE   | 0
[6]  | DSE3  | 1
[5]  | DSE2  | 1
[4]  | DSE1  | 1

[3]  | DSE0  | 1
[2]  | SPEED1| 1
[1]  | SPEED0| 1
[0]  | SRE   | 0

0001 1111 0111 1110

0x1F7E

 

Initializing is as follow

    IOMUXC_SetPinMux(IOMUXC_ECSPI2_MOSI_GPIO5_IO11, 0U);
    IOMUXC_SetPinConfig(IOMUXC_ECSPI2_MOSI_GPIO5_IO11, 0x1F7Eu);

 

@Chavira if you could explain why we have not used pin 16 as shown in the attached schematic showing  EXP_IO11 Expansion IO signal for GPIO5 at 11. I am not able to understand this. (Also shown in table 6 page 13 of attached hardware user guide.

Thanks


View solution in original post

0 Kudos
Reply
6 Replies
1,785 Views
imranhassan
Contributor II

Thanks @Chavira for your suggestions and showing the test video.

The main problem was I have not enabled PKE bit that enables internal pull up/down resistor. Second is setting full drive strength and full speed, I was able to get 3.3 volts at PIN number 19 (as corrected by @Chavira ). 

The details of register are as follow

Bits | Field | Value
-----|-------|------
[15] |       | 0
[14] |       | 0
[13] |       | 0
[12] | HYS   | 1

[11] | PUS1  | 1
[10] | PUS0  | 1
[9]  | PUE   | 1
[8]  | PKE   | 1

[7]  | ODE   | 0
[6]  | DSE3  | 1
[5]  | DSE2  | 1
[4]  | DSE1  | 1

[3]  | DSE0  | 1
[2]  | SPEED1| 1
[1]  | SPEED0| 1
[0]  | SRE   | 0

0001 1111 0111 1110

0x1F7E

 

Initializing is as follow

    IOMUXC_SetPinMux(IOMUXC_ECSPI2_MOSI_GPIO5_IO11, 0U);
    IOMUXC_SetPinConfig(IOMUXC_ECSPI2_MOSI_GPIO5_IO11, 0x1F7Eu);

 

@Chavira if you could explain why we have not used pin 16 as shown in the attached schematic showing  EXP_IO11 Expansion IO signal for GPIO5 at 11. I am not able to understand this. (Also shown in table 6 page 13 of attached hardware user guide.

Thanks


0 Kudos
Reply
1,842 Views
imranhassan
Contributor II

Thanks @Chavira for you reply and testing.

 

I am compiling program with vscode and mcuxpresso extension for vscode (as there is no support for imx8m mini evk in MCUXpresso IDE), running elf file using Ozone (JTAG). 

 

I checked both 18 and 19 pins with voltmeter but I am not able to see any voltage there.

 

I am using imx8mm-evk-rpmsg.dtb device tree file and LF_v6.6.36-2.1.0_images_IMX8MMEVK linux image on A53 side. What could be wrong i am not sure i even checked with default device tree which is imx8mm-evk.dtb but not having any luck. 

i can see the debug message of cortex M4 on debug console as well

0 Kudos
Reply
1,840 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @imranhassan!

 

You can compile and debug the iMX8MM in MCUXPRESSO for Visual Studio Code.

 

Please refer to the next app note for the same:

 

https://docs.nxp.com/bundle/AN14120/page/topics/introduction.html?_gl=1*13gw1i0*_ga*NjYzMTk1NjA4LjE3...

 

Best Regards!

Chavira

0 Kudos
Reply
1,835 Views
imranhassan
Contributor II
Thanks. Yes I am able to debug through vscode as well but Ozone shows memory details which seems better. Do you have any suggestion for GPIO working. I am even not able to check using Linux as it shows GPIO not found. In device tree it can be found and gpiodetect shows four chips.

Any suggestions?

Thanks for your concern
0 Kudos
Reply
1,820 Views
Chavira
NXP TechSupport
NXP TechSupport

Hi @imranhassan!

You want to use the gpio under M core or under A core?

If you want to use use that specific pin under Linux you should modify the device tree because that pin is being used by Linux in ECSPI2 peripheral.

Change the line 259 to status = "disabled"; to load the elf under Linux.

https://github.com/nxp-imx/linux-imx/blob/lf-6.1.y/arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi#L25...

 

Best Regards!

Chavira

 

0 Kudos
Reply
1,847 Views
Chavira
NXP TechSupport
NXP TechSupport

HI @imranhassan!

Thank you for contacting NXP Support!

 

How are compiling the program?

How you are loading  the binary to the M core?

 

I compiled the example and I get the led blinking.

 

Chavira_0-1731523799559.png

 

Note: The pin is the number 19 and the ground is on pin 20.

 

Best Regards!

Chavira

 

0 Kudos
Reply