Setting up 2 USARTs with DMA for LPC54018J4MET180, USART9 does not receive any data via DMA

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

Setting up 2 USARTs with DMA for LPC54018J4MET180, USART9 does not receive any data via DMA

Jump to solution
1,459 Views
jchen2023
Contributor II

We plan to use 2 usarts from LPC54018J4MET180, USART2 and USART9 on two different baud rates, one faster and the other slower. Our experience so far is that both of them can send with the configured baud rates but only one receives data via DMA0 on channel 4 and the other one does not receive anything on channel 22.

We want to get expert advice on the feasibility and the correct configurations step for both of them work the same time.

We are using Keil compiler and Arm\Packs\NXP\LPC54018M_DFP\12.2.1.

Labels (1)
0 Kudos
Reply
1 Solution
1,405 Views
jchen2023
Contributor II

Found an issue with the data receive code, it failed to call USART_TransferReceiveDMA for USART9. That's the reason, there is not data received via DMA. The above initUsart code works.

View solution in original post

0 Kudos
Reply
3 Replies
1,406 Views
jchen2023
Contributor II

Found an issue with the data receive code, it failed to call USART_TransferReceiveDMA for USART9. That's the reason, there is not data received via DMA. The above initUsart code works.

0 Kudos
Reply
1,406 Views
jchen2023
Contributor II

Found issues in my receive code that checks the buffer size. It didn't call the USART_TransferReceiveDMA for USART9. The above usartInit code works. Please close this out as solved.

0 Kudos
Reply
1,449 Views
jchen2023
Contributor II

Here is the uart set up code that results in USART2 working but USART9 doesn't receive from DMA:

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

* Local types and defines

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

 

#define RX_DMA_CHANNEL_FLEXCOMM2_RX 4

#define RX_DMA_CHANNEL_FLEXCOMM9_RX 22

 

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

* Local variables

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

 

static usart_dma_handle_t dmaHandle = {0};

 

static dma_handle_t rxHandle = {0};

 

static char printBuf[256] = {0};

 

static const char *CRLF = "\r\n";

 

 

static usart_dma_handle_t dmaHandle_0 = {0};

 

static dma_handle_t rxHandle_0 = {0};

 

static bool uart_status2 = false;  

static bool uart_status9 = false;

 

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

* Public functions

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

 

/**

* \brief Initialize the USART interface.

*/

void initUsart(void)

{

 

 

 

   // Connectivity port -

   CLOCK_AttachClk(kFRO12M_to_FLEXCOMM9);

   RESET_PeripheralReset(kFC9_RST_SHIFT_RSTn);

 

 

   DMA_Init(DMA0);

 

   usart_config_t config2 = {0};

   USART_GetDefaultConfig(&config2);

   config2.baudRate_Bps = 115200;

   config2.enableTx = true;

   config2.enableRx = true;

 

   USART_Init(USART9, &config2, CLOCK_GetFlexCommClkFreq(9));

 

   DMA_EnableChannel(DMA0, RX_DMA_CHANNEL_FLEXCOMM9_RX);

   DMA_CreateHandle(&rxHandle_0, DMA0, RX_DMA_CHANNEL_FLEXCOMM9_RX);

 

   if (kStatus_Success != USART_TransferCreateHandleDMA(USART9, &dmaHandle_0, NULL, NULL, NULL, &rxHandle_0))

   {

      uart_status9 = true;

   }

      

   CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);

   RESET_PeripheralReset(kFC2_RST_SHIFT_RSTn);

 

   usart_config_t config = {0};

   USART_GetDefaultConfig(&config);

   config.baudRate_Bps = 750000;

   config.enableTx = true;

   config.enableRx = true;

 

   USART_Init(USART2, &config, CLOCK_GetFlexCommClkFreq(2));

 

   DMA_EnableChannel(DMA0, RX_DMA_CHANNEL_FLEXCOMM2_RX);

   DMA_CreateHandle(&rxHandle, DMA0, RX_DMA_CHANNEL_FLEXCOMM2_RX);

 

   if (kStatus_Success == USART_TransferCreateHandleDMA(USART2, &dmaHandle, NULL, NULL, NULL, &rxHandle))

   {

      uart_status2 = true;

 

   }

 

 

}

0 Kudos
Reply