MCUXpresso

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

MCUXpresso

Jump to solution
2,029 Views
tonytao
Contributor III

Hi,

I have FRDM-K22F Board, and I try to light the RGB Led on the board. According to the user guide <FRDMK22FUG.pdf>, the Red color controlled by pin PTA1, the Green controlled by Pin PTA2. On the MCU datasheet <K22F Sub-Family Reference Manual> page1359, address 400F_F014 is port data direction register, address 400F_F000 is port Data Output Register.

I use MCUXpresso IDE to import example <frdmk22f_hello_world, and add codes as below:

   PRINTF("hello world.\r\n");

 

    *(int*)0x400FF014 = 0x02; //set PTA1 as Output – my code

    *(int*)0x400FF000 = 0x02; //set PTA1 as High, so the led should be red -my code

 

 

    while (1)

    {

        ch = GETCHAR();

        PUTCHAR(ch);

}

There is no error to “Build” and “Debug”, but the RGB Led always keep green.

Appreciate for any help on this.

Labels (1)
1 Solution
1,686 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Tony Tao ,

Please set PTA1 to low , then the RED LED should be on .

Have a look at the schematic of FRDM-K22 board :

pastedImage_1.png


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

7 Replies
1,686 Views
tonytao
Contributor III

Hi Alice,

Appreciate your reply, I was using Kinetis Design Studio 3 IDE and Processor Expert, and be advised to use MCUXpresso.

I was expect the MCUXpresso and config tool should is as easy as Processor Expert.

and on the Processor Expert, there is a way to W/R register directly. that is why the question come from.

but thank you again for your time, it help a lot.

have a good day!

0 Kudos
1,686 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Tony,

You are welcome .

In MCUXpresso IDE, you can also use  Pins Tool, Clocks Tool and Peripherals Tool to configure

like Processor Expert, about detail please take a look at "MCUXpresso_IDE_User_Guide.pdf"

->12. MCUXpresso Config Tools .


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,686 Views
tonytao
Contributor III

    *(int*)0x400FF014 = 0x06;    //set PTA1 (Red) & PTA2 (Green) as Output
    *(int*)0x400FF0D4 = 0x20;   //Set PTD5 (Blue) as Output
    *(int*)0x400FF000 = 0x06;    //set PTA1 & PTA2 as High
    *(int*)0x400FF0C0 = 0x20;   //set PTD5 as High

that is the code I wrote. I set all PTA1, PTA2, PTD5 to High, and the RGB LED should be OFF, but the LED just keep Green.

and I tried different setting (like set PTA1 as low), but it look like the code did nothing on it, just the LED keep green. Did I do something wrong else?

0 Kudos
1,686 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Tony,

Firtly, please enable the clock of PORTA and PORTD,

then config PTA1 PTA2 and PTD5 to as GPIO :

  CLOCK_EnableClock(kCLOCK_PortA);  
  CLOCK_EnableClock(kCLOCK_PortD);  

  PORT_SetPinMux(PORTA, 1U, kPORT_MuxAsGpio);   
  PORT_SetPinMux(PORTA, 2U, kPORT_MuxAsGpio); 
  PORT_SetPinMux(PORTD, 5U, kPORT_MuxAsGpio); 
  
 *(int*)0x400FF014 = 0x06;    //set PTA1 (Red) & PTA2 (Green) as Output         *(int*)0x400FF0D4 = 0x20;   //Set PTD5 (Blue) as Output    
 *(int*)0x400FF000 = 0x06;    //set PTA1 & PTA2 as High   
 *(int*)0x400FF0C0 = 0x20;   //set PTD5 as High‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope it help,


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,686 Views
tonytao
Contributor III

Hi Alice,

thank you so much for you replay!

But I still have two problem:

1. when I add the code above and try to build the code , I got an Error of  'kPORT_MuxAsGpio' undeclared (first use in this function) and the building stop at :

PORT_SetPinMux(PORTA, 1U, kPORT_MuxAsGpio);

when I try to open the pins icon,

pastedImage_2.jpg

the IDE tell me No processor selected, but on the Project Settings - MCU, the setting is MK22FN512VLH12 already.

pastedImage_3.jpg

2. could you please tell me what is GPIO clock, why I have to Enable it? and what does "PORT_SetPinMux(PORTA, 1U, kPORT_MuxAsGpio);" doing?

0 Kudos
1,686 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Tony,

1. The definition of "kPORT_MuxAsGpio" is in fsl_port.h file ,  please include it :

#include "fsl_port.h"

2. Before we use the port , we need to first enable the clock , please have a look at the Reference Manule of your chip :

pastedImage_3.png

3. I was wondering why you  configure registers by yourself on by one ,  you  can use SDK driver to configure,

also there is gpio demo under SDK package :

pastedImage_4.png


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,687 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Tony Tao ,

Please set PTA1 to low , then the RED LED should be on .

Have a look at the schematic of FRDM-K22 board :

pastedImage_1.png


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------