<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic [S32K144] How to receive multiple bytes using UART when in VRPR mode in S32K</title>
    <link>https://community.nxp.com/t5/S32K/S32K144-How-to-receive-multiple-bytes-using-UART-when-in-VRPR/m-p/1186550#M8916</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How to receive multiple bytes using UART when in VRPR mode (or VRPS mode)?&lt;BR /&gt;When I try to receive multiple bytes, I get a status = STATUS_UART_RX_OVERRUN.&lt;/P&gt;&lt;P&gt;I am writing this based on lpuart_echo_s32k144 in Example Projects.&lt;BR /&gt;Here's the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#include "Cpu.h"&lt;BR /&gt;#include "pin_mux.h"&lt;BR /&gt;#include "dmaController1.h"&lt;BR /&gt;#include "clockMan1.h"&lt;BR /&gt;#include "lpuart1.h"&lt;BR /&gt;#include "pwrMan1.h"&lt;/P&gt;&lt;P&gt;volatile int exit_code = 0;&lt;BR /&gt;/* User includes (#include below this line is not maintained by Processor Expert) */&lt;BR /&gt;#include &amp;lt;string.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdint.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdbool.h&amp;gt;&lt;/P&gt;&lt;P&gt;/* Welcome message displayed at the console */&lt;BR /&gt;#define welcomeMsg "This example is an simple echo using LPUART\r\n\&lt;BR /&gt;it will send back any character you send to it.\r\n\&lt;BR /&gt;The board will greet you if you send 'Hello Board'\r\&lt;BR /&gt;\nNow you can begin typing:\r\n"&lt;/P&gt;&lt;P&gt;/* Error message displayed at the console, in case data is received erroneously */&lt;BR /&gt;#define errorMsg "An error occurred! The application will stop!\r\n"&lt;/P&gt;&lt;P&gt;/* Timeout in ms for blocking operations */&lt;BR /&gt;#define TIMEOUT 100U&lt;/P&gt;&lt;P&gt;/* Receive buffer size */&lt;BR /&gt;#define BUFFER_SIZE 256U&lt;/P&gt;&lt;P&gt;#define RUN (0u) /* High speed run */&lt;BR /&gt;#define VLPR (1u) /* Run */&lt;BR /&gt;#define VLPS (2u) /* Very low power run */&lt;/P&gt;&lt;P&gt;/* Buffer used to receive data from the console */&lt;BR /&gt;uint8_t buffer[BUFFER_SIZE];&lt;BR /&gt;uint8_t bufferIdx;&lt;/P&gt;&lt;P&gt;/* UART rx callback for continuous reception, byte by byte */&lt;BR /&gt;void rxCallback(void *driverState, uart_event_t event, void *userData)&lt;BR /&gt;{&lt;BR /&gt;/* Unused parameters */&lt;BR /&gt;(void)driverState;&lt;BR /&gt;(void)userData;&lt;/P&gt;&lt;P&gt;/* Check the event type */&lt;BR /&gt;if (event == UART_EVENT_RX_FULL)&lt;BR /&gt;{&lt;BR /&gt;/* The reception stops when newline is received or the buffer is full */&lt;BR /&gt;if ((buffer[bufferIdx] != '\n') &amp;amp;&amp;amp; (bufferIdx != (BUFFER_SIZE - 2U)))&lt;BR /&gt;{&lt;BR /&gt;/* Update the buffer index and the rx buffer */&lt;BR /&gt;bufferIdx++;&lt;BR /&gt;LPUART_DRV_SetRxBuffer(INST_LPUART1, &amp;amp;buffer[bufferIdx], 1U);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt;\brief The main function for the project.&lt;BR /&gt;\details The startup initialization sequence is the following:&lt;BR /&gt;* - startup asm routine&lt;BR /&gt;* - main()&lt;BR /&gt;*/&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;/* Write your local variable definition here */&lt;BR /&gt;status_t status;&lt;BR /&gt;/* Declare a buffer used to store the received data */&lt;BR /&gt;uint32_t bytesRemaining;&lt;/P&gt;&lt;P&gt;/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/&lt;BR /&gt;#ifdef PEX_RTOS_INIT&lt;BR /&gt;PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */&lt;BR /&gt;#endif&lt;BR /&gt;/*** End of Processor Expert internal initialization. ***/&lt;/P&gt;&lt;P&gt;/* Write your code here */&lt;BR /&gt;/* For example: for(;;) { } */&lt;/P&gt;&lt;P&gt;/* Initialize and configure clocks&lt;BR /&gt;* - see clock manager component for details&lt;BR /&gt;*/&lt;BR /&gt;CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,&lt;BR /&gt;g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);&lt;BR /&gt;CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);&lt;/P&gt;&lt;P&gt;/* Initialize pins&lt;BR /&gt;* - See PinSettings component for more info&lt;BR /&gt;*/&lt;BR /&gt;PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);&lt;/P&gt;&lt;P&gt;/* Initialize LPUART instance */&lt;BR /&gt;LPUART_DRV_Init(INST_LPUART1, &amp;amp;lpuart1_State, &amp;amp;lpuart1_InitConfig0);&lt;BR /&gt;/* Install the callback for rx events */&lt;BR /&gt;LPUART_DRV_InstallRxCallback(INST_LPUART1, rxCallback, NULL);&lt;BR /&gt;/* Send a welcome message */&lt;BR /&gt;LPUART_DRV_SendDataBlocking(INST_LPUART1, (uint8_t *)welcomeMsg, strlen(welcomeMsg), TIMEOUT);&lt;/P&gt;&lt;P&gt;/* Infinite loop:&lt;BR /&gt;* - Receive data from user&lt;BR /&gt;* - Echo the received data back&lt;BR /&gt;*/&lt;BR /&gt;POWER_SYS_Init(&amp;amp;powerConfigsArr, POWER_MANAGER_CONFIG_CNT, &amp;amp;powerStaticCallbacksConfigsArr, POWER_MANAGER_CALLBACK_CNT);&lt;BR /&gt;POWER_SYS_SetMode(VLPR, POWER_MANAGER_POLICY_AGREEMENT);&lt;BR /&gt;//POWER_SYS_SetMode(VLPS, POWER_MANAGER_POLICY_AGREEMENT);&lt;BR /&gt;while (1)&lt;BR /&gt;{&lt;BR /&gt;/* Receive and store data byte by byte until new line character is received,&lt;BR /&gt;* or the buffer becomes full (256 characters received)&lt;BR /&gt;*/&lt;BR /&gt;LPUART_DRV_ReceiveData(INST_LPUART1, buffer, 3U);&lt;BR /&gt;/* Wait for transfer to be completed */&lt;BR /&gt;while(LPUART_DRV_GetReceiveStatus(INST_LPUART1, &amp;amp;bytesRemaining) == STATUS_BUSY);&lt;/P&gt;&lt;P&gt;/* Check the status */&lt;BR /&gt;status = LPUART_DRV_GetReceiveStatus(INST_LPUART1, &amp;amp;bytesRemaining);&lt;/P&gt;&lt;P&gt;if (status != STATUS_SUCCESS)&lt;BR /&gt;{&lt;BR /&gt;/* If an error occurred, send the error message and exit the loop */&lt;BR /&gt;LPUART_DRV_SendData(INST_LPUART1, (uint8_t *)errorMsg, strlen(errorMsg));&lt;BR /&gt;break;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* Append string terminator to the received data */&lt;BR /&gt;bufferIdx++;&lt;BR /&gt;buffer[bufferIdx] = 0U;&lt;/P&gt;&lt;P&gt;/* Send the received data back */&lt;BR /&gt;LPUART_DRV_SendData(INST_LPUART1, buffer, bufferIdx);&lt;BR /&gt;/* Reset the buffer index to start a new reception */&lt;BR /&gt;bufferIdx = 0U;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*** Don't write any code pass this line, or it will be deleted during code generation. ***/&lt;BR /&gt;/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/&lt;BR /&gt;#ifdef PEX_RTOS_START&lt;BR /&gt;PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */&lt;BR /&gt;#endif&lt;BR /&gt;/*** End of RTOS startup code. ***/&lt;BR /&gt;/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/&lt;BR /&gt;for(;;) {&lt;BR /&gt;if(exit_code != 0) {&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return exit_code;&lt;BR /&gt;/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best regards&lt;/P&gt;</description>
    <pubDate>Fri, 20 Nov 2020 08:17:02 GMT</pubDate>
    <dc:creator>KK2</dc:creator>
    <dc:date>2020-11-20T08:17:02Z</dc:date>
    <item>
      <title>[S32K144] How to receive multiple bytes using UART when in VRPR mode</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-How-to-receive-multiple-bytes-using-UART-when-in-VRPR/m-p/1186550#M8916</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How to receive multiple bytes using UART when in VRPR mode (or VRPS mode)?&lt;BR /&gt;When I try to receive multiple bytes, I get a status = STATUS_UART_RX_OVERRUN.&lt;/P&gt;&lt;P&gt;I am writing this based on lpuart_echo_s32k144 in Example Projects.&lt;BR /&gt;Here's the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#include "Cpu.h"&lt;BR /&gt;#include "pin_mux.h"&lt;BR /&gt;#include "dmaController1.h"&lt;BR /&gt;#include "clockMan1.h"&lt;BR /&gt;#include "lpuart1.h"&lt;BR /&gt;#include "pwrMan1.h"&lt;/P&gt;&lt;P&gt;volatile int exit_code = 0;&lt;BR /&gt;/* User includes (#include below this line is not maintained by Processor Expert) */&lt;BR /&gt;#include &amp;lt;string.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdint.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdbool.h&amp;gt;&lt;/P&gt;&lt;P&gt;/* Welcome message displayed at the console */&lt;BR /&gt;#define welcomeMsg "This example is an simple echo using LPUART\r\n\&lt;BR /&gt;it will send back any character you send to it.\r\n\&lt;BR /&gt;The board will greet you if you send 'Hello Board'\r\&lt;BR /&gt;\nNow you can begin typing:\r\n"&lt;/P&gt;&lt;P&gt;/* Error message displayed at the console, in case data is received erroneously */&lt;BR /&gt;#define errorMsg "An error occurred! The application will stop!\r\n"&lt;/P&gt;&lt;P&gt;/* Timeout in ms for blocking operations */&lt;BR /&gt;#define TIMEOUT 100U&lt;/P&gt;&lt;P&gt;/* Receive buffer size */&lt;BR /&gt;#define BUFFER_SIZE 256U&lt;/P&gt;&lt;P&gt;#define RUN (0u) /* High speed run */&lt;BR /&gt;#define VLPR (1u) /* Run */&lt;BR /&gt;#define VLPS (2u) /* Very low power run */&lt;/P&gt;&lt;P&gt;/* Buffer used to receive data from the console */&lt;BR /&gt;uint8_t buffer[BUFFER_SIZE];&lt;BR /&gt;uint8_t bufferIdx;&lt;/P&gt;&lt;P&gt;/* UART rx callback for continuous reception, byte by byte */&lt;BR /&gt;void rxCallback(void *driverState, uart_event_t event, void *userData)&lt;BR /&gt;{&lt;BR /&gt;/* Unused parameters */&lt;BR /&gt;(void)driverState;&lt;BR /&gt;(void)userData;&lt;/P&gt;&lt;P&gt;/* Check the event type */&lt;BR /&gt;if (event == UART_EVENT_RX_FULL)&lt;BR /&gt;{&lt;BR /&gt;/* The reception stops when newline is received or the buffer is full */&lt;BR /&gt;if ((buffer[bufferIdx] != '\n') &amp;amp;&amp;amp; (bufferIdx != (BUFFER_SIZE - 2U)))&lt;BR /&gt;{&lt;BR /&gt;/* Update the buffer index and the rx buffer */&lt;BR /&gt;bufferIdx++;&lt;BR /&gt;LPUART_DRV_SetRxBuffer(INST_LPUART1, &amp;amp;buffer[bufferIdx], 1U);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt;\brief The main function for the project.&lt;BR /&gt;\details The startup initialization sequence is the following:&lt;BR /&gt;* - startup asm routine&lt;BR /&gt;* - main()&lt;BR /&gt;*/&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;/* Write your local variable definition here */&lt;BR /&gt;status_t status;&lt;BR /&gt;/* Declare a buffer used to store the received data */&lt;BR /&gt;uint32_t bytesRemaining;&lt;/P&gt;&lt;P&gt;/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/&lt;BR /&gt;#ifdef PEX_RTOS_INIT&lt;BR /&gt;PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */&lt;BR /&gt;#endif&lt;BR /&gt;/*** End of Processor Expert internal initialization. ***/&lt;/P&gt;&lt;P&gt;/* Write your code here */&lt;BR /&gt;/* For example: for(;;) { } */&lt;/P&gt;&lt;P&gt;/* Initialize and configure clocks&lt;BR /&gt;* - see clock manager component for details&lt;BR /&gt;*/&lt;BR /&gt;CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,&lt;BR /&gt;g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);&lt;BR /&gt;CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);&lt;/P&gt;&lt;P&gt;/* Initialize pins&lt;BR /&gt;* - See PinSettings component for more info&lt;BR /&gt;*/&lt;BR /&gt;PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);&lt;/P&gt;&lt;P&gt;/* Initialize LPUART instance */&lt;BR /&gt;LPUART_DRV_Init(INST_LPUART1, &amp;amp;lpuart1_State, &amp;amp;lpuart1_InitConfig0);&lt;BR /&gt;/* Install the callback for rx events */&lt;BR /&gt;LPUART_DRV_InstallRxCallback(INST_LPUART1, rxCallback, NULL);&lt;BR /&gt;/* Send a welcome message */&lt;BR /&gt;LPUART_DRV_SendDataBlocking(INST_LPUART1, (uint8_t *)welcomeMsg, strlen(welcomeMsg), TIMEOUT);&lt;/P&gt;&lt;P&gt;/* Infinite loop:&lt;BR /&gt;* - Receive data from user&lt;BR /&gt;* - Echo the received data back&lt;BR /&gt;*/&lt;BR /&gt;POWER_SYS_Init(&amp;amp;powerConfigsArr, POWER_MANAGER_CONFIG_CNT, &amp;amp;powerStaticCallbacksConfigsArr, POWER_MANAGER_CALLBACK_CNT);&lt;BR /&gt;POWER_SYS_SetMode(VLPR, POWER_MANAGER_POLICY_AGREEMENT);&lt;BR /&gt;//POWER_SYS_SetMode(VLPS, POWER_MANAGER_POLICY_AGREEMENT);&lt;BR /&gt;while (1)&lt;BR /&gt;{&lt;BR /&gt;/* Receive and store data byte by byte until new line character is received,&lt;BR /&gt;* or the buffer becomes full (256 characters received)&lt;BR /&gt;*/&lt;BR /&gt;LPUART_DRV_ReceiveData(INST_LPUART1, buffer, 3U);&lt;BR /&gt;/* Wait for transfer to be completed */&lt;BR /&gt;while(LPUART_DRV_GetReceiveStatus(INST_LPUART1, &amp;amp;bytesRemaining) == STATUS_BUSY);&lt;/P&gt;&lt;P&gt;/* Check the status */&lt;BR /&gt;status = LPUART_DRV_GetReceiveStatus(INST_LPUART1, &amp;amp;bytesRemaining);&lt;/P&gt;&lt;P&gt;if (status != STATUS_SUCCESS)&lt;BR /&gt;{&lt;BR /&gt;/* If an error occurred, send the error message and exit the loop */&lt;BR /&gt;LPUART_DRV_SendData(INST_LPUART1, (uint8_t *)errorMsg, strlen(errorMsg));&lt;BR /&gt;break;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* Append string terminator to the received data */&lt;BR /&gt;bufferIdx++;&lt;BR /&gt;buffer[bufferIdx] = 0U;&lt;/P&gt;&lt;P&gt;/* Send the received data back */&lt;BR /&gt;LPUART_DRV_SendData(INST_LPUART1, buffer, bufferIdx);&lt;BR /&gt;/* Reset the buffer index to start a new reception */&lt;BR /&gt;bufferIdx = 0U;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*** Don't write any code pass this line, or it will be deleted during code generation. ***/&lt;BR /&gt;/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/&lt;BR /&gt;#ifdef PEX_RTOS_START&lt;BR /&gt;PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */&lt;BR /&gt;#endif&lt;BR /&gt;/*** End of RTOS startup code. ***/&lt;BR /&gt;/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/&lt;BR /&gt;for(;;) {&lt;BR /&gt;if(exit_code != 0) {&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return exit_code;&lt;BR /&gt;/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;best regards&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 08:17:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-How-to-receive-multiple-bytes-using-UART-when-in-VRPR/m-p/1186550#M8916</guid>
      <dc:creator>KK2</dc:creator>
      <dc:date>2020-11-20T08:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: [S32K144] How to receive multiple bytes using UART when in VRPR mode</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-How-to-receive-multiple-bytes-using-UART-when-in-VRPR/m-p/1187279#M8947</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is your baudrate? Can you try to use 9600?&lt;/P&gt;
&lt;P&gt;Also, what is your source clock for LPUART?&lt;/P&gt;
&lt;P&gt;Have you set the SIRC clock as a clock source for the LPUART?&lt;/P&gt;
&lt;P&gt;If you share the whole project, I can check the Processor Expert settings.&lt;/P&gt;
&lt;P&gt;About the LPUART in VLPS, please, see the table below (RM rev. 12.1):&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dianabatrlova_3-1606118161473.png" style="width: 591px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/130733i51870435492E7D8D/image-dimensions/591x102?v=v2" width="591" height="102" role="button" title="dianabatrlova_3-1606118161473.png" alt="dianabatrlova_3-1606118161473.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dianabatrlova_0-1606118046638.png" style="width: 600px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/130730i741D8B1882DA3FA3/image-dimensions/600x69?v=v2" width="600" height="69" role="button" title="dianabatrlova_0-1606118046638.png" alt="dianabatrlova_0-1606118046638.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dianabatrlova_2-1606118104355.png" style="width: 608px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/130732i634E72962BD6EF5E/image-dimensions/608x60?v=v2" width="608" height="60" role="button" title="dianabatrlova_2-1606118104355.png" alt="dianabatrlova_2-1606118104355.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I hope it helps.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Diana&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 08:02:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-How-to-receive-multiple-bytes-using-UART-when-in-VRPR/m-p/1187279#M8947</guid>
      <dc:creator>dianabatrlova</dc:creator>
      <dc:date>2020-11-23T08:02:22Z</dc:date>
    </item>
  </channel>
</rss>

