Proper way to reconfigure uart

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

Proper way to reconfigure uart

1,298 Views
vasudhevan
Contributor V

Hi,

    Board - imxrt1064

    We are configuring baudrate, and parity from http server.

    I have followed below procedure to deinit uart.

 

		/************* Disable UART **************/
		//LPUART_SoftwareReset(ELM_UART6_MODBUS_MASTER);
		sys_msleep(100);
		LPUART_DisableInterrupts(ELM_UART6_MODBUS_MASTER, kLPUART_IdleLineInterruptEnable | kLPUART_ParityErrorInterruptEnable);
		LPUART_Deinit(ELM_UART6_MODBUS_MASTER);
		sys_msleep(100);
		/************* Disable DEAMUX *************/
		DMAMUX_Deinit(PQ_DMAMUX_BASE_ADDRESS);
		//DMAMUX_DisableChannel(PQ_DMAMUX_BASE_ADDRESS, PQ_MOD_SLAVE_TX_DMA_CHANNEL);
		//DMAMUX_DisableChannel(PQ_DMAMUX_BASE_ADDRESS, PQ_MOD_SLAVE_RX_DMA_CHANNEL);
		sys_msleep(100);
		/************* Disable EDMA ***************/
		//EDMA_StopTransfer(&g_pq_mod_slaveRxEdmaHandle);
		//EDMA_Deinit(PQ_MOD_SLAVE_DMA_BASE_ADD);

     While deinit board is not working there only code is crashed.

     How to deinit uart and again init uart peripheral ?

Thanks & Regards,

       Vasu

   

 

Labels (1)
Tags (1)
0 Kudos
5 Replies

1,292 Views
jeremyzhou
NXP Employee
NXP Employee

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Please follow the below code to reconfigure the lpuart module.

LPUART_Deinit(DEMO_LPUART);
LPUART_Init(DEMO_LPUART, &config, DEMO_LPUART_CLK_FREQ);


Have a great day,
TIC

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,286 Views
vasudhevan
Contributor V

Hi @jeremyzhou,

     Thanks for your reply.

     We have modified above mentioned code but it's not working.

     In isr callback function DMA receive data as 0.

     How to solve dma issue ?

 

Thanks & Regards,

     Vasu

        

0 Kudos

1,279 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply.
I've done the test with the lpuart_polling demo in the SDK library, in the demo, the default baud rate is 115200, and after reconfiguration, the baud rate become 19200, it still can transfer the string successfully and I attach the code below.

/*
 * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc.
 * Copyright 2016-2017 NXP
 * All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "board.h"
#include "fsl_lpuart.h"

#include "pin_mux.h"
#include "clock_config.h"
/*******************************************************************************
 * Definitions
 ******************************************************************************/
#define DEMO_LPUART LPUART1
#define DEMO_LPUART_CLK_FREQ BOARD_DebugConsoleSrcFreq()

/*******************************************************************************
 * Prototypes
 ******************************************************************************/

/*******************************************************************************
 * Variables
 ******************************************************************************/

uint8_t txbuff[]   = "Lpuart polling example\r\nBoard will send back received characters\r\n";
uint8_t Test_buff[]   = "Proper way to reconfigure uart\r\n";
uint8_t rxbuff[20] = {0};

/*******************************************************************************
 * Code
 ******************************************************************************/

/*!
 * @brief Main function
 */
int main(void)
{
    uint8_t ch;
    lpuart_config_t config;

    BOARD_ConfigMPU();
    BOARD_InitPins();
    BOARD_BootClockRUN();

    /*
     * config.baudRate_Bps = 115200U;
     * config.parityMode = kLPUART_ParityDisabled;
     * config.stopBitCount = kLPUART_OneStopBit;
     * config.txFifoWatermark = 0;
     * config.rxFifoWatermark = 0;
     * config.enableTx = false;
     * config.enableRx = false;
     */
    LPUART_GetDefaultConfig(&config);
    config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
    config.enableTx     = true;
    config.enableRx     = true;

    LPUART_Init(DEMO_LPUART, &config, DEMO_LPUART_CLK_FREQ);

    LPUART_WriteBlocking(DEMO_LPUART, txbuff, sizeof(txbuff) - 1);


    LPUART_Deinit(DEMO_LPUART);
    config.baudRate_Bps = 19200U;
    LPUART_Init(DEMO_LPUART, &config, DEMO_LPUART_CLK_FREQ);
    LPUART_WriteBlocking(DEMO_LPUART, Test_buff, sizeof(Test_buff) - 1);

    while (1)
    {
        LPUART_ReadBlocking(DEMO_LPUART, &ch, 1);
        LPUART_WriteBlocking(DEMO_LPUART, &ch, 1);
    }
}

jeremyzhou_0-1604910926201.png

 


So regarding your question, I don't think it was related to reconfiguring operation, and you'd better go through the code careful.
Have a great day,
TIC

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,255 Views
vasudhevan
Contributor V

Hi @jeremyzhou,

      Thanks for your reply.

      UART is working but read values from EDMA it will be zero.

      I have refereed evkmimxrt1064_lpuart_edma_rb_transfer example code.

      But EDMA_GetRemainingMajorLoopCount function receiving value zeros not proper value.

      If we deinit uart driver no need to deinit edma ?

Thanks & Regards,

      Vasu

0 Kudos

1,245 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply.
1) If we deinit uart driver no need to deinit edma ?
-- Yes.
Have a great day,
TIC

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos