MAPS-KS22 oobe demo with KSDK V2.0 software porting guide

Document created by Hui_Ma Employee on Jun 14, 2016Last modified by ebiz_ws_prod on Dec 13, 2017
Version 3Show Document
  • View in full screen mode
  • MAPS-KS22 Board Introduction:

MAPS boards are localization evaluation boards for Chinese customers. The MAPS boards are suitable for NXP MCU product, with low coat, more flexibility and easy-copy features, which matching with local customer requirements and better for learning and product evaluation.

MAPS board includes four parts board, which are MCU Board, Peripheral Board, Application Board & Socket Board.

The naming of MAPS are using the four-part board initial letter.




MCU Board.pngMCU board is NXP Kinetis MCU based evaluation main board with chip related special module interface/device, such as graphic LCD/ENET interface and etc. The MCU board fan out all MCU pins as test points for measuring. The MCU board also provide two 32-pin socket to connect external peripheral board or application board.




Peripheral Board.pngPeripheral Board collects more general device into one board and using two 32-pin socket connects with MCU board. The MAPS-Dock is the first peripheral board, which with below configuration: Micor-SD card slot; six touch pads; USB FS interface; IrDA transceiver; one SPI Interface (SPI-Flash); two UART interface; four buttons; one I2S interface (audio codec); one CAN interface; two potentionmeter; one DAC output interface; 128x64 monochrome LCD; one 5-way button. It also with SWD debugger on board and USB CDC virtual COM.


Application Board designed for special applications, such as motor control, IOT, Smart Home, Wireless Charger and etc.


Socket Board provides interface for FreeDOM boards/Arduino boards/Customer defined boards.


MAPS-KS22 board MCU board for KS22 chip evaluation. KS22 MCU is based on the ARM® Cortex®-M4 core with 120MHz MCUs with FPU, offering full-speed USB 2.0 OTG, in addition to other features like USB crystal-less functionality.


  • MAPS-KS22 oobe demo porting process

MAPS-KS22 oobe demo is based KSDK V1.0, which will show Freescale LOGO on the SPI color LCD and meanwhile use FlexIO I2S to play an audio on microphone.


Step1: visit Kinetis Expert website ( to download MAPS-KS22 KSDK V2.0 software:


Step2: download [Kinetis SDK Project Generator Tool] from below link and generate oobe demo project based on MAPS-KS22 SDK V2.0 software:



Step 3: After that, open the oobe project, which located at default path:


The default project is based on <hello-world> demo, it need to add LED control code. Those part of code could be found at <main.c> file and related pin muxing code at <pin_mux.c> file.


Step 4: Modify ili9341 related driver:

For the oobe project with two major functions, the first one is to display Freescale LOGO at LCD. The MAPS-KS22 board graphic LCD is using ili9341 TFT LCD driver with SPI interface with KS22 chip. The previous oobe project is using GPIO pins emulate SPI communication, we will make the similar application with KSDK V2.0 driver. Most modification based on the GPIO pins control. Please check below code at <ili9341.h> file, which call KSDK V2.0 GPIO driver:

#define ILI9341_CS_HIGH()       GPIO_SetPinsOutput(BOARD_LCD_CS_GPIO, 1U << BOARD_LCD_CS_PIN)

#define ILI9341_CS_LOW()        GPIO_ClearPinsOutput(BOARD_LCD_CS_GPIO, 1U << BOARD_LCD_CS_PIN)

#define ILI9341_CLK_HIGH()      GPIO_SetPinsOutput(BOARD_LCD_CLK_GPIO, 1U << BOARD_LCD_CLK_PIN) 

#define ILI9341_CLK_LOW()       GPIO_ClearPinsOutput(BOARD_LCD_CLK_GPIO, 1U << BOARD_LCD_CLK_PIN)


#define ILI9341_MOSI_LOW()      GPIO_ClearPinsOutput(BOARD_LCD_MOSI_GPIO, 1U << BOARD_LCD_MOSI_PIN)     


#define ILI9341_MISO_LOW()      GPIO_ClearPinsOutput(BOARD_LCD_MISO_GPIO, 1U << BOARD_LCD_MISO_PIN)

And it also need to add ili9341 control pin muxing initialization code at <pin_mux.c> file.


Step 5: We could modify the Freescale logo with new NXP logo, which could using [Embedded GUI Conversion Utility3.0] tool.

This tool could be downloaded from below link: 

The conversion result of the graphic data is 16-bit array, which need be transfer to 8-bit array. After that, compile and download the image to the board, it with below result:



Step 6: The oobe demo provide another function to play music with MAPS-DOCK board WM8960 codec chip, then using headphone will hear the sound.2016-06-14_17-24-40.png

For the KS22 with FlexIO module, the demo will use FlexIO emulating I2S bus to transfer data to WM8960 codec chip. About I2S bus MCLK clock source, the MAPS-KS22 provide two selection, one is using TPM1_CH1 pin, the other one is using I2S0_MCLK pin with JP5 jumper selection. In oobe demo, we use TPM1_CH1 pin to generate 12MHz MCLK clock with TPM module output compare mode. Related code, please refer below tpm_init_output_compare() function at <main.c> file:

//enable clock gating of tpm1


//set TMP output compare mode



TPM_StartTimer(BOARD_TPM_BASEADDR, kTPM_SystemClock);   //TPM counter increments on every TPM counter clock

Step 7: WM8960 is a stereo CODEC chip provide I2C port for chip configuration.

There need to initialization the WM8960 chip before using it with related driver <wm8960.c> & <wm8960.h> files. The MAPS-KS22 board using LPI2C0 module connects with WM8960 chip, so there need to port using LPI2C driver of KSDK V2.0 and modify the WM8960 driver related. The LPI2C module initialization code located at <main.c> with lpi2c_master_init() function. The WM8960 driver major modification with WOLFSON_WriteReg() function at <wm8960.c> file, calling the LPI2C driver of KSDK V2.0 with below code: 

wolfson_status_t WOLFSON_WriteReg(uint8_t reg, uint16_t val)


      uint8_t cmd,buff;

       status_t ret;

       cmd = (reg << 1) | ((val >> 8) & 0x0001);    // register address

       buff = val & 0xFF;     //data

       reg_cache[reg] = val;      // copy data to cache

        uint8_t data[2];

        data[0] = cmd;

        data[1] = buff;

        //start lpi2c tx operation


         ret = LPI2C_MasterStart(LPI2C0, WM8960_I2C_ADDR, kLPI2C_Write);  

        // send two data with register address and related value

         ret = LPI2C_MasterSend(LPI2C0, data, 2);      

         //stop lpi2c tx operation        

         ret = LPI2C_MasterStop(LPI2C0);     

         if(ret != kStatus_Success)

         {  return kStatus_WOLFSON_I2CFail;  }

         return kStatus_WOLFSON_Success;


After WM8960 chip driver modification, there could call related driver to initialize WM8960 chip and configure the communication interface with I2S bus. Following steps focus on how to transfer data to WM8960 codec with I2S bus.


Step 8:  The FlexIO modul will simulate I2S bus call FlexIO_I2S_MasterInit() function in <main.c> file to initialize FlexIO module as I2S master.

There using FXIO0_D4 pin as I2S bit clock pin, using FXIO0_D5 pin as I2S Transmit pin and using FXIO0_D6 pin as I2S Transmit Frame Sync pin. KSDK V2.0 provide FlexIO for I2S driver located at <fsl_flexio_i2s.h> file.


Step 9: There will call eDMA with FlexIO module to reduce the core work load during the I2S data transfer.

It will initialize the eDMA & DMAMUX modules for FlexIO. Related code located at <main.c> file with ConfigDMAforFlexIOI2STX() function:

void ConfigDMAforFlexIOI2STX(void)



EDMA_Init(EXAMPLE_DMA, &dmaConfig);







Step 10: KSDK V2.0 software provides FlexIO I2S eDMA driver located at <fsl_flexio_i2s_edma.c> file,

with below codes to initialize FlexIO I2S master DMA handler and to configure the sample rate & audio data format to be transferred:

FLEXIO_I2S_TransferTxCreateHandleEDMA(&base, &txHandle, callback, NULL, &dmaHandle);

FLEXIO_I2S_TransferSetFormatEDMA(&base, &txHandle, &format, 48000000);


Step 11: After above preparation, following action will start to transfer music data to WM8960 codec with below code.

When the music data transfer finished, the callback function will be called to start next round data transferred. Then we could hear the sound with endless loop.

static void callback(FLEXIO_I2S_Type *i2sBase, flexio_i2s_edma_handle_t *handle, status_t status, void *userData)


  // Initiate FlexIO I2S transfer again after previous transfer finished 

FLEXIO_I2S_TransferSendEDMA(&base, &txHandle, &xfer);





About more detailed oobe demo software info, please check attached file.

The default oobe demo located path is:


Original Attachment has been moved to:

2 people found this helpful