FRDM-MCXN947 GPIO_PortClear() not working and why?

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

FRDM-MCXN947 GPIO_PortClear() not working and why?

Jump to solution
455 Views
saulius1005
Contributor II

Hi, My problem is simple- Recently I just start play with FRDM-MCXN947 board. According to tutorial I create C project file. My first test should be Green color  simple on and off (onboard RGB led) . Program written by me looks like that:

    while(1) {
        i++ ;
        if(i==1){
        	GPIO_PortSet(BOARD_INITDEBUG_UARTPINS_LED_GREEN_PORT, BOARD_INITDEBUG_UARTPINS_LED_GREEN_PIN_MASK);
        }
        if(i==20000000){
        	GPIO_PortClear(BOARD_INITDEBUG_UARTPINS_LED_GREEN_PORT, BOARD_INITDEBUG_UARTPINS_LED_GREEN_PIN_MASK);
        }
        if(i==40000000){
        	i=0;
        }
        /* 'Dummy' NOP to allow source level single stepping of
            tight while() loop */
        __asm volatile ("nop");
    }

 

I just did some changes (main source file) inside while loop and other part is not changed at all.

I try run debugging and GREEN led turn on but never turn off. Of course I did changes in required pin changes with integrated config tool. Also here printscreens from main source file, pinmux and config screens:config screenconfig screen

 

port_mux.hport_mux.h

 

main.cmain.c

 

 

0 Kudos
1 Solution
419 Views
saulius1005
Contributor II

Problem solved instead of this

BOARD_INITDEBUG_UARTPINS_LED_GREEN_PORT

use this:

BOARD_INITDEBUG_UARTPINS_LED_GREEN_GPIO

or this:

BOARD_INITLEDSPINS_LED_GREEN_GPIO

but why same defined twice with different names...?

Code after all changes: 

    while(1) {
        i++ ;
        if(i==1){
        	GPIO_PortSet(BOARD_INITLEDSPINS_LED_GREEN_GPIO, BOARD_INITLEDSPINS_LED_GREEN_PIN_MASK);
        }
        else if(i==2000000){
        	GPIO_PortClear(BOARD_INITLEDSPINS_LED_GREEN_GPIO, BOARD_INITLEDSPINS_LED_GREEN_PIN_MASK);
        }
        else if(i==4000000){
        	i=0;
        }
        /* 'Dummy' NOP to allow source level single stepping of
            tight while() loop */
        __asm volatile ("nop");
    }

View solution in original post

0 Kudos
5 Replies
422 Views
saulius1005
Contributor II

Those files already included trought board.h (at least I think so):

Ekrano kopija 2024-03-18 013758.png

 

And bdw  all project files is automatically generated. And my opinion all necessary files and includes should be inside.

Tags (1)
0 Kudos
427 Views
saulius1005
Contributor II

gpio driver version 2.7.3:

GPIO_PortClear at fsl_gpio.hGPIO_PortClear at fsl_gpio.h

 

0 Kudos
426 Views
JoeSanchez
Contributor II
I don't see fsl_gpio.h is added as part of #includes, try adding that and make sure that fsl_gpio.c and .h is part of your project so it will be compiled
0 Kudos
441 Views
JoeSanchez
Contributor II

Are you using SDK 2.5? If i remember correctly, fsl_gpio.h PortClear and PortSet has 3 arguments. verify your version of gpio driver you are using

JoeSanchez_0-1710715845780.png

 



0 Kudos
420 Views
saulius1005
Contributor II

Problem solved instead of this

BOARD_INITDEBUG_UARTPINS_LED_GREEN_PORT

use this:

BOARD_INITDEBUG_UARTPINS_LED_GREEN_GPIO

or this:

BOARD_INITLEDSPINS_LED_GREEN_GPIO

but why same defined twice with different names...?

Code after all changes: 

    while(1) {
        i++ ;
        if(i==1){
        	GPIO_PortSet(BOARD_INITLEDSPINS_LED_GREEN_GPIO, BOARD_INITLEDSPINS_LED_GREEN_PIN_MASK);
        }
        else if(i==2000000){
        	GPIO_PortClear(BOARD_INITLEDSPINS_LED_GREEN_GPIO, BOARD_INITLEDSPINS_LED_GREEN_PIN_MASK);
        }
        else if(i==4000000){
        	i=0;
        }
        /* 'Dummy' NOP to allow source level single stepping of
            tight while() loop */
        __asm volatile ("nop");
    }
0 Kudos