Adding to Peripherials and GPIO to Project

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

Adding to Peripherials and GPIO to Project

1,266 Views
burgeh
Contributor IV

Greetings,

I am using the K22FN256LVH12 on a custom board, and just switched my project from KDS to MCUXpresso. I followed how to port this project to MCUXpresso and I am able to compile and run the current code I have.

However, I am wondering the best course of to add new components to the code. For example just toggling a GPIO, I go into the pins menu, but when I ported this all I was to delete the board.h file, so this doesn't really work then. I see where I can initialize the pin to a certain value, but no function or anything to actually change its states within my main.c code. Is it all register manipulation? If so, could you please direct me to a useful resource with the register info, the regular datasheet does not seem to mention much.

Thanks!

Labels (1)
0 Kudos
5 Replies

1,025 Views
marek-trmac
NXP Employee
NXP Employee

Hi Christopher,

Peripherals tool generates `peripherals.c` and `peripherals.h` source files (use `Update Project` button to get them updated). Once you have these files generated, you should call `BOARD_InitBootPeripherals();` from your main function. This function calls all other functions selected to be called during initialization.

For pin routing, the corresponding function called from main is `BOARD_InitBootPins()` from pin_mux.c

Regards

Marek

Regards,
Marek
0 Kudos

1,025 Views
burgeh
Contributor IV

To clarify, I deleted all the base startup headers when I ported my project from KDS to MCUXpresso following BlackNight, and his tutorial. I'm not quite sure how to regenerate these files for use or even if I can.

For example for my MK22FN256 I would like to set pin 32 to GPIO and be able to toggle it in the main of my code.

The image below I believe shows me setting it to a GPIO, but I'm a bit lost on how this BOARD_InitPins function will be implemented since I removed the board file. I also am a bit lost on the actual function or command to set the pin high or low.

pastedImage_3.png

0 Kudos

1,025 Views
BlackNight
NXP Employee
NXP Employee

Hi Christopher,

the Pins tools does the Pin Muxing and not the actual GPIO driver code. The following tutorial written for an earlier (but still applicable) version of the Pins Tool should help you:

Tutorial: Muxing with the New NXP Pins Tool | MCU on Eclipse 

Erich

0 Kudos

1,025 Views
burgeh
Contributor IV

I understand that the pins tool just muxes the pin for it's functionality. However, it seems I cannot add in these functions since I ported in my KDS v3.2 Processor Expert project, since I need the drivers of GPIO and Port. When those are included I get errors with my imported pin functions.

So to clarify completely. Am I able to use the Pin tool or Peripheral functions that MCUXpresso uses, on an imported KDS v3.2 Project with Processor Expert. If that is so, could I please get some information on how to meld the two together nicely?

0 Kudos

1,025 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Christopher,

The register information is introduced in reference manual. Please download this document from Arm® Cortex®-M4|Kinetis® K22 120 MHz 32-bit USB MCUs|NXP .

Regards,

Jing

0 Kudos