¿Does the Shell use the LPUART of the R41Z?

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

¿Does the Shell use the LPUART of the R41Z?

1,356 Views
cral_martin
Contributor II

Hi community,

I'm using the example of the R41Z eval board "thread_router_eligible_device" on the eval board.

First of all the goal is to send a frame through the Serial Port of the slave when a button of the master is pressed. 

I'm trying to use the LPUART to send the String "Hello World" when a button is pressed through the Serial Port while the app of the eligible device is running. I write the code and it doesn't have any problems but it doesn't print on the Console "Hello World" as the example does.

I know how to use the Shell and that it comunicates via SerialManager (using the lpuart) with the PC to print stuff like temperature, IP of the devices, etc on the prompt. Do you know if, maybe, I cannot use the function "PRINTF("Hello World");" -which use the uart- to print on the Console because the uart is being used?

What would you try to send frames via Serial Port?

Thank you all for your help, regards

Cristina.

static void APP_AppModeHandleKeyboard ( uint32_t keyEvent )
{           
         switch(keyEvent)    
         {
         case gKBD_EventPB1_c:          
                 /* Data sink create */  
                         (void)NWKU_SendMsg(APP_SendDataSinkCreate, NULL, mpAppThreadMsgQueue);            
                 break;

#if gKBD_KeysCount_c > 1                     /* If button 4 is pressed (temp) */        
                  case gKBD_EventPB2_c:            
                  /* Report temperature */                              
                          (void)NWKU_SendMsg(APP_ReportTemp, NULL, mpAppThreadMsgQueue);

/////////////////////////////////////////////////            
                           HolaMundo()   
                          /* Pressing button4, send a string by serial port */

//////////////////////////////////////////////////            
                  break;       
                  case gKBD_EventPB3_c: 

....................................................           ----- (keeps going)


I've written all the includes needed
///////////////////////
#include "fsl_lpuart.h"

#include "GPIO_Adapter.h"
#include "gpio_pins.h"

#include "pin_mux.h"
#include "fsl_debug_console.h"
#include <stdio.h>
////////////////////////

I use the same function as in the hello world example

/************************************************************************************** *              

     HITO 2: Hello World (Serial Port - UART) 
**************************************************************************************/

void HolaMundo (void)
{
        BOARD_InitLPUART();
        BOARD_BootClockRUN();
        BOARD_InitDebugConsole();
 PRINTF("Hola Mundo.\r\n");
}


With all this done I don't get the "hello world" printed in the screen. 

I do initialize the correct ports:

void BOARD_InitLPUART void
{
       CLOCK_EnableClock(kCLOCK_PortC);

       PORT_SetPinMux(PORTC, PIN6_IDX, kPORT_MuxAlt4); 
       PORT_SetPinMux(PORTC, PIN7_IDX, kPORT_MuxAlt4);            
       SIM->SOPT5 = ((SIM->SOPT5 &    
       (~(SIM_SOPT5_LPUART0RXSRC_MASK)))
         | SIM_SOPT5_LPUART0RXSRC(SOPT5_LPUART0RXSRC_LPUART_RX)           );
}

I use the BootClockRUN as is given (no changes)
And finally the part which I don't know if it makes sense, I use the BOARD_InitDebugConsole given in the "hello world" example

/* Initialize debug console. */
void BOARD_InitDebugConsole ( void )
{   
        uint32_t uartClkSrcFreq;
        CLOCK_SetLpuartClock(2);

        uartClkSrcFreq = BOARD_DEBUG_UART_CLK_FREQ;


        DbgConsole_Init(BOARD_DEBUG_UART_BASEADDR, BOARD_DEBUG_UART_BAUDRATE, 
                                    BOARD_DEBUG_UART_TYPE,            uartClkSrcFreq);
}

Labels (2)
Tags (4)
9 Replies

1,098 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

The shell indeed uses the LPUART.

The approach you are using of taking the function of the hello world example and just place it on the Hola_Mundo function will only overwrite the configurations already in the project. 

The example you are using, already has the configuration you added in case you want to print the "Hola Mundo" in the shell, please check the following implementation used in the example:

    /* Print temperature in shell */
    shell_write("\r");
    shell_write((char *)pTempString);
    shell_refresh();
    MEM_BufferFree(pTempString);

If you want to send something to another board through the serial port when a push button it's pressed and print it in the screen, you will need two board initialization for the UART, for different pins and different LPUART modules. 

If you have any question, let me know.

Regards

Estephania

1,098 Views
cral_martin
Contributor II

First of all, thank you for your answer, Estephania.

I already use the shell to print the message that I'm sending using CoAP (from one node to another), but now that the second node has received the message I want to send it again through the Serial Port.

I understand what you say, but on the datasheet of the R41Z it says there is only one LPUART module. I've seen the pinout: PTC6 and PTC7, PTC2 and PTC3, PTC17 and PTC18; they can be used as RX and TX, respectively, but they are all for the LPUART0 module. Can I use one of the above as second UART or as they use the same module (LPUART) I just can't send more messages through the Serial Port using the UART? Should I do it using, for example, one of the SPI modules?

Thank you again for all your help!

Regards

Cristina

0 Kudos

1,098 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

Sorry you are right , I was confused with another wireless device, this one only has one UART.

Just to make sure, you want to show it in both the shell and another interface, is that correct?

If you are already using the shell, the best option I can think of for you it's to look to send it through SPI or I2C as you mention, you might also find helpful some kind or converter.

Regards,

Estephania

1,098 Views
cral_martin
Contributor II

Hello,

The first R41Z device has a button, when I press that button I send a CoAP message to a second R41Z device so that 2nd device knows that the button's been pressed and send a command (which is a 11 bits frame) through the Serial Port to turn on or turn off a light. The 1st device uses the shell so that I can write commands, read the message that I'm sending and read the CoAP message I'm getting back from the 2nd device. This 2nd device doesn't need to use the shell, I can join it to an existing network by pressing twice a button, what I want it to do is to send a command when it has received the message from the 1st device using the Serial Port. It doesn't matter if it uses the LPUART, the I2C or the SPI nor if it uses the shell or it doesn't. Untill now I've been using the shell in both devices to know what I was doing reading the messages on the screen, but now I could stop using the shell of the second device, as I know I'm sending and receiving the CoAP correctly, and use it to send the frame.

By now I already has the program where I send and receive that message, what is left is the part of using the serial port of the second device to send the command to the lightning system.

 

Thank you for your help and support!

Regards,

Cristina

0 Kudos

1,098 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

If you only need to do that, you can try changing the pins only and use the same initialization. I believe you already solved that, is my understanding correct? if it is not, do you still have doubts? just let me know. 

Regards,

Estephania

0 Kudos

1,098 Views
cral_martin
Contributor II

Yes, I thought so, but I've erased everything related with the shell in the program of the second device and changed the pin configuration (I took again the thread_eligible_device as base) but it still doesn't work.

What should I do? I just want to use the second device as router_elegible_device but using the LPUART to transmit data instead of using it for the shell (as I don't need the shell on the second device anymore).

Thank you for all your help!

Kindly regards, 

Cristina.

0 Kudos

1,098 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

The easiest solution for you might be to reuse the serial manager from the Shell initialization, have you tried that ?

Also, it might be better to start step by step, the first step I would recommend it's to redirect the shell pins and verify that you are getting the information and printing.

After that i would recommend to remove the usage of shell with the define to only send then the information you want with those pins.

Right now we are quite busy, so I can;t make a full code example for you, but if you have troubles while trying to implement that, you can ask here so I can try to check it, also, I'll try to work on that whenever I have some time.

Regards,

Estephania

0 Kudos

1,098 Views
cral_martin
Contributor II

Hello Estephania,

Thank you for your time, I've already solved the problem by not including the shell.

Regards,

Cristina

0 Kudos

1,098 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

Thank you for letting us know.

Regards,

Estephania

0 Kudos