MQX ITTYC Not installing (name not found) KSDK1.2.0 KDS

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

MQX ITTYC Not installing (name not found) KSDK1.2.0 KDS

1,685 Views
danielhadley
Contributor I

Hi all,

I'm trying to use a second UART for serial communication on the K64F development board. I'm using the version of MQX supplied with KSDK1.2.0 (which I believe is 4.2), and have a processor expert enabled project. I've successfully got a webserver running, and the debug serial output (tty) works perfectly. The problem comes when I use PEX to add another UART.

I've configured it to be UART2, and assigned it pins. I can confirm it works using the KSDK functions to write and read, but I want to use the MQX drivers so I can use fopen. I've placed the following in user_config.h:

#define BSPCFG_ENABLE_TTYC 0

#define BSPCFG_ENABLE_ITTYC 1

Then I've rebuilt the following projects I have added to the workspace:

Untitled.png

After doing this I build my project, stepping through in the debugger I get to the line where I open the tty:

Int_com =  fopen("ittyc:","w");

This fails when it looks up the name "ittyc:", the only files present in the list are my tfs file for the webserver, tty, and the serial driver for tty. To me it seems like the driver isnt getting installed at all, Ive tried adding the BSPCFG enable lines to the "User settings" section of the mqx_ksdk PEX component and i still encounter the same error.

Looking in my project structure, in SDK->rtos->mqx->mqx->source->bsp->init_bsp.c only the debug tty gets initialized. Am I facing a problem where the BSP isnt getting built correctly, maybe I've got the project structure set up wrong. If I go back and look at the MQX 4.1 source files the user_config.h file already has all of the BSPCFG defines populated, in the 4.2 user_config.h there is only:

 

#ifndef __user_config_h__

#define __user_config_h__

/* Define user specific modifications of default configuration*/

#define BSPCFG_HAS_SRAM_POOL           1

/* Include platform-specific configuration */

#include "mqx_cnfg.h"

#endif /* __user_config_h__ */

/*!

** @}

*/

/*

** ###################################################################

**

**     This file was created by Processor Expert 10.5 [05.21]

**     for the Freescale Kinetis series of microcontrollers.

**

** ###################################################################

*/

This is the user config generated by processor expert, notice that the two added lines in the main MQX user config don't show up here. The two i added using the "user settings" show up in another file generated by processor expert.

Id really appreciate any help or direction people can provide, its been stumping me a while now.

Labels (1)
0 Kudos
6 Replies

965 Views
soledad
NXP Employee
NXP Employee

Hello Daniel,

I think it is a little misunderstanding. The Kinetis SDK provides a set of drivers for the Kinetis MCU product family on-chip peripherals. The drivers are designed and implemented around the peripheral hardware blocks rather than for a specific Kinetis MCU, and work with or without an OS through the OS Abstraction layer. The drivers are architected into two layers: the Hardware Abstraction Layer and the Peripheral Driver Layer.

These drivers are different than the MQX 4.xxx drivers, so you cannot use the BSPCFG_ENABLE_TTYC nor BSPCFG_ENABLE_ITTYC definitions.

You need to use the KSDK drivers. At the path C:\Freescale\KSDK_1.2.0\examples\frdmk64f\driver_examples\uart, you can find some UART examples that you can use as reference.

In addition please check the below threads:

https://community.freescale.com/message/501499#501499

https://community.freescale.com/thread/351020

https://community.freescale.com/docs/DOC-104516

https://community.freescale.com/thread/352326

https://community.freescale.com/thread/351714


Have a great day,
Sol

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

0 Kudos

965 Views
danielhadley
Contributor I

Ah I see, thank you for the response! So in MQX 4.2 that functionality isnt there, as its designed for the KSDK?

How is it possible that the UART configured for debug is a PEX component (grouped with the MQX component), yet is opened by MQX in init_bsp using the MQX drivers? Am I not able to do something similar for UART2, so I can use fopen?

0 Kudos

965 Views
soledad
NXP Employee
NXP Employee

This thread may helps

MQX with KSDK and Processor Expert

Regards

Sol

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

0 Kudos

965 Views
danielhadley
Contributor I

Thanks Sol, everything seems to be suggesting that the MQX drivers will only work with the UART set as the default debug output. Is that correct?

0 Kudos

965 Views
soledad
NXP Employee
NXP Employee

Hello Daniel,

You can select the UART that you need.

For example if you debug the hello MQX for KSDK example (C:\Freescale\KSDK_1.2.0\rtos\mqx\mqx\examples\hello\build\kds), the default console is the UART1 (OpenSDA - USB mini connector). However you can change it in the board.h file  please check the below image.

If you use PE you can select the UART that you need.

pastedImage_0.png

Regards

Sol

0 Kudos

965 Views
danielhadley
Contributor I

I have the UART I need selected. What I am trying to do is have two UART serial ports configured at once. One for diagnostics output, and one for communication with other modules that will be connected to the micro. I wanted to be able to use fopen and fread with both of those ports and was having difficulty with it. I have solved one of the problems but am still encountering others. I'll explain what I've done first.

I have the debug output configured to UART0 in board.h as you have said. I have then added these definitions to the "User settings" section of the MQX PEX component to start configuring my second communication channel:

#define BOARD_ALTERNATE_UART_INSTANCE   2

#define BOARD_ALTERNATE_UART_BASEADDR   UART2_BASE

#define ALT_SERIAL_DEVICE "ttyc"

I've then edited the SDK->rtos->mqx->mqx->source->bsp->init_bsp.c file to initialise and configure my second UART alongside the first one. To do this I've added the following initialisation options:

const NIO_SERIAL_INIT_DATA_STRUCT nio_serial_alternate_init =

    {

        .SERIAL_INSTANCE     = BOARD_ALTERNATE_UART_INSTANCE,

        .BAUDRATE            = 38400,

        .PARITY_MODE         = kNioSerialParityDisabled,

        .STOPBIT_COUNT       = kNioSerialOneStopBit,

        .BITCOUNT_PERCHAR    = 8,

        .RXTX_PRIOR          = 4,

        .MODULE              = NIO_SERIAL_DEF_MODULE,

    /* Always second clock source configuration is used. It can be :kClockLpuartSrcPllFllSel, kClockLpsciSrcPllFllSel, kClockLpuartSrcIrc48M)*/

    /* For UART this is dummy value */

        .CLK_SOURCE          = 1,

    };

Then I've duplicated the BSP_DEFAULT_IO_CHANNEL initialisation:

/* Install serial driver for alternate input and output */

    res = _nio_dev_install(BSP_ALTERNATE_IO_CHANNEL, &nio_serial_dev_fn, (void*) &nio_serial_alternate_init,NULL);

    assert(NULL != res);

/* Instal and set tty driver */

    res = _nio_dev_install("ttyc:", &nio_tty_dev_fn, (void*)&(NIO_TTY_INIT_DATA_STRUCT){BSP_ALTERNATE_IO_CHANNEL, 0},NULL);

    assert(NULL != res);

    //    close(0);

    fd = open("ttyc:", NIO_TTY_FLAGS_EOL_RN | NIO_TTY_FLAGS_ECHO);  // 0 - stdin

    assert(fd == 4);

    //    close(1);

    fd = open("ttyc:", NIO_TTY_FLAGS_EOL_RN | NIO_TTY_FLAGS_ECHO);  // 1 - stdout

    assert(fd == 6);

    //    close(2);

    fd = open("ttyc:", NIO_TTY_FLAGS_EOL_RN | NIO_TTY_FLAGS_ECHO);  // 2 - stderr

    assert(fd == 7);

By doing this I have been able to use fopen("ttyc",0) to open to second UART.

My current issue is how to use fread in a non blocking manner. As far as I can see fread is meant to return the number of characters read, but my program hangs at fread until any characters are received. How do I get it to return 0 if there is nothing at that moment, or read if there are bytes to be read?

0 Kudos