K22 Pin Mux Tool

cancel
Showing results for 
Search instead for 
Did you mean: 

K22 Pin Mux Tool

Jump to solution
1,016 Views
chrismoncsko
Contributor I

Hello,

     We're developing several products with the Kinetis K22 family microcontrollers (specifically the MK22FN1M0VLL12), and need a pin muxing tool that supports this chip. Perhaps there is a config file that you have for the K22's that will work with IOMux?


Thank you,

Chris

Labels (1)
Tags (5)
0 Kudos
1 Solution
221 Views
mjbcswitzerland
Specialist V

Hi Chris

I can't help with IOMux but I can show you a tool which allows simple configuration and verification.

I just set it up for the TWR-K21F120M (closest to a K22 based board) but modified the pinout for 100 pin K22. The result can be checked out here: http://www.uTasker.com/freescale/kinetis_K22.zip There is an exe called uTasker_K22 in the zip file which can be executed (needs no installation) and all port pins, their functions and connections for that device and package can be seen, as well as how it is presently configured [hover the mouse over the port pins of interest].

To configure ports and peripherals the code uses macros like

_CONFIG_PERIPHERAL(E, 17, PE_17_UART2_RX); // configures UART2 Rx input on port PTE-17

Complete configurations can be set up in the user code and the simulator then shows the port functions so that accuracy can be verified. Setups for new Kinetis devices and packages are easy to add and are then available to use for such verification work. There is further functionality which allows things like port interrupt configuration and their interrupt routines to be verified and tested. The port configuration part can however prove useful alone for much project setup work.

Regards

Mark

View solution in original post

0 Kudos
3 Replies
222 Views
mjbcswitzerland
Specialist V

Hi Chris

I can't help with IOMux but I can show you a tool which allows simple configuration and verification.

I just set it up for the TWR-K21F120M (closest to a K22 based board) but modified the pinout for 100 pin K22. The result can be checked out here: http://www.uTasker.com/freescale/kinetis_K22.zip There is an exe called uTasker_K22 in the zip file which can be executed (needs no installation) and all port pins, their functions and connections for that device and package can be seen, as well as how it is presently configured [hover the mouse over the port pins of interest].

To configure ports and peripherals the code uses macros like

_CONFIG_PERIPHERAL(E, 17, PE_17_UART2_RX); // configures UART2 Rx input on port PTE-17

Complete configurations can be set up in the user code and the simulator then shows the port functions so that accuracy can be verified. Setups for new Kinetis devices and packages are easy to add and are then available to use for such verification work. There is further functionality which allows things like port interrupt configuration and their interrupt routines to be verified and tested. The port configuration part can however prove useful alone for much project setup work.

Regards

Mark

View solution in original post

0 Kudos
221 Views
chrismoncsko
Contributor I

Thank you very much Mark, this is quite helpful. Is there a document somewhere that describes how to set up the user code (.sim file, right?) for the simulator and perhaps a legend for the symbols on each pin (^ means input with pullup, P means peripheral, etc.)? For example, how do I set a pin as input, etc. _CONFIG_PERIPHERAL(D, 4, PD_4_INPUT); ?

Chris

0 Kudos
221 Views
mjbcswitzerland
Specialist V

Chris

1. Meaning of ports:

^ the pin is an input and has a '1' applied to it (if you click on the port you can toggle the input state - this can be read by code and generates interrupts if the port is configured for the edge). If you click on the buttons on the board you will see that they are in fact hooked up to inputs so that the buttons could be reacted to.

v - the pin is an input and pulled down (the default state after a reset can be configured for each pin to match pull-ups/downs in a particular design (default is all pulled-up).

P - configured as peripheral (many pins in the Kinetis default to a peripheral function) - the one selected is displayed by hovering the mouse over the port pin.

1 or 0 - configured as GPIO output, showing the logical drive state. Note that one output is toggling and connected to an LED on the board which is then toggling too.

2. The *.sim files are scripts that can control various simulation sequences. Eg. PTC-2 input can be driven high for 50ms after 200ms, then driven low, etc. This allows testing port input sequences (when more simple manual control is not suitable). Also UART receptions can be injected, or USB frames on certain endpoints etc., This applies to various communication interface (like Ethernet, SPI) as well as anogue input values.

The .sim files don't have anything to do with the port configurations or directly testing them.

3. The port configurations are performed in real Kinetis code and then tested in the environment. Here is a list of most configuration and control macros (in form of examples). They have the advantage that they include hooks to the simulator to allow it to check that the code has set things up correctly, as well as controlling ports as the code operates. They generate complete configuration code (including powering up ports) and are very code-efficient (in comparison to calling configuration library routines). Multiple port pins on a port can be configured at the same time as long as they use the same characteristics

_CONFIG_PORT_OUTPUT(A, PORTA_BIT24, (PORT_SRE_SLOW));

_CONFIG_DRIVE_PORT_OUTPUT_VALUE(B, SPI2_CS0, SPI2_CS0, (PORT_SRE_FAST | PORT_DSE_HIGH));

_WRITE_PORT(E, 0x12345678);

_WRITE_PORT_MASK(C, (PORTC_BIT16 | PORTC_BIT18),  LCD_BUS_MASK);

_TOGGLE_PORT(D, K60_LED_GREEN);

_CONFIG_PORT_INPUT(B, (PORTB_BIT24 |PORTB_BIT25) , (PORT_PS_UP_ENABLE));

_READ_PORT(E);

_READ_PORT_MASK(A, 0x0000ff00);

_CONFIG_PERIPHERAL(B, 1,  (PB_1_I2C0_SDA | PORT_ODE | PORT_PS_UP_ENABLE));

_SETBITS(C, USB_HOST_POWER_ENABLE);

_CLEARBITS(C, USB_HOST_POWER_ENABLE);

4. There are two main possibilities for using this:

- if starting a new project, the complete environment can be used on all K and KL processors. It starts with a complete project (with USB and TCP/IP stacks, FAT, etc.  and various drivers - depending on processor types capability) which are then enabled or disabled as required. The project runs completely in the simulator environments (displaying ports, communicating using scripts or with the real world by hooking up the Kinetis peripheral simulations to PC COM ports, the Ethernet NIC, or even CAN buses). The code is all C-code which can be built in the VisualStudio envoirnment where the embedded code can be tested and debugged in (approximale) real-time. When the work has been prepared the same code is cross-compiled and loaded to a real HW for final verification (or low level development of time critical stuff that can't be performed in the PC environment). Codewarrior, IAR, Keil, Rowley Crossworks, GCC or Atollic can be used since the project builds and operates with all.

- if you already have a developed project or need to use a different OS, stack etc. you can still use the port simulation by adding your configuration code (eg. in a single routine) and testing that it is OK. Once satisfied, copy the macros to the other project environment as well as the tested configuration and it should be fine for the HW like that. The final environmnet would be more constrained to developing and testing on the HW so will generally be less efficient overall.

5. This means that to use the project (either completely or just the port simulation) you need VisualStudio (the free express edition is adequate). You can get the complete project code from KINETIS Project Code .

Note that only the K20 and K21 pinouts are in the latest release but I added the K22 pinout for a quick test (but not the ADC pins). Adding new processor types is quite easy if needed.

I'll send you the file in case you would like to add it, but you can already test almost any Freecale board as it is.

Regards

Mark

0 Kudos