IMXRT1024 LPUART and EDMA Handler Management

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

IMXRT1024 LPUART and EDMA Handler Management

Jump to solution
2,256 Views
Lukas_Frank
Senior Contributor I

Hi Dear Authorized,

 

I am using LPUART with eDMA in IMXRT1024. The case that I want to accomplish is evaluate the results all 8-UART in one handler. I just want to all UART come back to the same IRQHandler method. after the system IRQ is fired. Then, calculating received bytes as common in same place for all UART. In default EDMA Ring Buffer SDK example, you can see the following lines:

 

 

#define EXAMPLE_LPUART_IRQHandler      LPUART1_IRQHandler
#define EXAMPLE_LPUART_IRQn            LPUART1_IRQn

 

 

 

 

void EXAMPLE_LPUART_IRQHandler(void)
{
    uint32_t status            = LPUART_GetStatusFlags(EXAMPLE_LPUART);
    uint32_t enabledInterrupts = LPUART_GetEnabledInterrupts(EXAMPLE_LPUART);

    /* If new data arrived. */
    if ((0U != ((uint32_t)kLPUART_IdleLineFlag & status)) &&
        (0U != ((uint32_t)kLPUART_IdleLineInterruptEnable & enabledInterrupts)))
    {
        (void)LPUART_ClearStatusFlags(EXAMPLE_LPUART, kLPUART_IdleLineFlag);
        isIdleLineDetected = true;
        receivedBytes      = EXAMPLE_RING_BUFFER_SIZE -
                        EDMA_GetRemainingMajorLoopCount(EXAMPLE_LPUART_DMA_BASEADDR, LPUART_RX_DMA_CHANNEL);
        receivedBytes += (EXAMPLE_RING_BUFFER_SIZE * ringBufferFlag) - ringBufferIndex;

        if (receivedBytes > 32U)
        {
            __NOP();
        }
    }
    LPUART_TransferEdmaHandleIRQ(EXAMPLE_LPUART, &g_lpuartEdmaHandle);
    SDK_ISR_EXIT_BARRIER;
}

 

 

I do not want to define a method for all of 8 UART as below:

(Below is not what I want)

 

 

#define EXAMPLE_LPUART_IRQHandler1      LPUART1_IRQHandler
#define EXAMPLE_LPUART_IRQn1            LPUART1_IRQn

#define EXAMPLE_LPUART_IRQHandler2      LPUART2_IRQHandler
#define EXAMPLE_LPUART_IRQn2            LPUART2_IRQn

#define EXAMPLE_LPUART_IRQHandler3      LPUART3_IRQHandler
#define EXAMPLE_LPUART_IRQn3            LPUART3_IRQn

#define EXAMPLE_LPUART_IRQHandler4      LPUART4_IRQHandler
#define EXAMPLE_LPUART_IRQn4            LPUART4_IRQn
...
..
.

 

 

I want to use all of 8 UART in my system. All handlers will do same work. How can I do this? Could you help me please?

Thanks and Regards.

0 Kudos
Reply
1 Solution
2,180 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Let me clarify it.
1) What does optime the interrupt function?
-- I mean that the developers don't place the codes for calculation or other complicated codes in the interrupt function, for the interrupt function, the simpler is better and leave time-costly code in the main function to handle.
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.
-------------------------------------------------------------------------------

View solution in original post

7 Replies
2,225 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
1) Do you have an idea to operate functionality of CallBack like IRQHandler?
-- To be honest, I don't have.
Actually, in my opinion, the evkmimxrt1024_lpuart_edma_rb_transfer seems like a toy demo, the EXAMPLE_LPUART_IRQHandler() is not a good way to calculating the receivedBytes, why do you consider using kLPUART_RxDataRegFullInterruptEnable interrupt to calculate the receivedBytes.
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.
-------------------------------------------------------------------------------

2,217 Views
Lukas_Frank
Senior Contributor I

Hi Dear @jeremyzhou ,

Thank you for your advice. I don't know how can I do your feedback.

 

Q1: Will it return us exact amount of received bytes ? How ? If you want, I can create a new issue about topic.

Q2: For example, I will create the system as you advice. Then, 98 Bytes are transferred to my UART. Will my system be under interrupt for 98 times?

Q3: Will it not be cause to performance decreasing?

 

Thanks and Regards.

0 Kudos
Reply
2,198 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Q2: For example, I will create the system as you advice. Then, 98 Bytes are transferred to my UART. Will my system be under interrupt for 98 times?
-- The key point is what exact purpose you want to make, for instance, in your design, the UART will receive a unpredict a number of data frames, it'd better select the interrupt mode to receive and calculate the number of received data frames.
Q3: Will it not be cause to performance decreasing?
-- Maybe, it will enter the interrupt continually on the condition that a large of continual string data is coming, however, it can optime the interrupt function to decrease executing time to handle the condition.
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.
-------------------------------------------------------------------------------

2,190 Views
Lukas_Frank
Senior Contributor I

Hi Dear @jeremyzhou ,

 

I didn't catch the meaning by your words "it can optime the interrupt function to decrease executing time to handle the condition." what means "it" here? What does optime the interrupt function?

 

Thanks and Regards.

0 Kudos
Reply
2,181 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Let me clarify it.
1) What does optime the interrupt function?
-- I mean that the developers don't place the codes for calculation or other complicated codes in the interrupt function, for the interrupt function, the simpler is better and leave time-costly code in the main function to handle.
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.
-------------------------------------------------------------------------------

2,242 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Firstly, the multiple LPUART modules have their specific interrupt number, in another word, they will enter different interrupt functions respectively when interrupting event happens.
To implement your purpose, you can define a common callback function that is called in the above different interrupt functions.
Hope it helps.
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.
-------------------------------------------------------------------------------

2,237 Views
Lukas_Frank
Senior Contributor I

Hi Dear @jeremyzhou ,

 

I tried it before post issue but I failed in while calculating receivedBytes in IRQHandler (Here). I think the hierachy for calling these two methods in program flow are different. So receivedBytes calculating a little bit different in Callback and IRQHandler. Do you have an idea to operate functionality of CallBack like IRQHandler? I just want to define common CallBack method and this CallBack method do same task pointed (Here2)

Here:

...
..
. 
receivedBytes      = EXAMPLE_RING_BUFFER_SIZE -                     EDMA_GetRemainingMajorLoopCount(EXAMPLE_LPUART_DMA_BASEADDR, LPUART_RX_DMA_CHANNEL);
receivedBytes += (EXAMPLE_RING_BUFFER_SIZE * ringBufferFlag) - ringBufferIndex;
.
..
...

 

Here2:

void EXAMPLE_LPUART_IRQHandler(void)//I just want this will be CallBack 
{
    uint32_t status            = LPUART_GetStatusFlags(EXAMPLE_LPUART);
    uint32_t enabledInterrupts = LPUART_GetEnabledInterrupts(EXAMPLE_LPUART);

    /* If new data arrived. */
    if ((0U != ((uint32_t)kLPUART_IdleLineFlag & status)) &&
        (0U != ((uint32_t)kLPUART_IdleLineInterruptEnable & enabledInterrupts)))
    {
        (void)LPUART_ClearStatusFlags(EXAMPLE_LPUART, kLPUART_IdleLineFlag);
        isIdleLineDetected = true;
        receivedBytes      = EXAMPLE_RING_BUFFER_SIZE -
                        EDMA_GetRemainingMajorLoopCount(EXAMPLE_LPUART_DMA_BASEADDR, LPUART_RX_DMA_CHANNEL);
        receivedBytes += (EXAMPLE_RING_BUFFER_SIZE * ringBufferFlag) - ringBufferIndex;

        if (receivedBytes > 32U)
        {
            __NOP();
        }
    }
    LPUART_TransferEdmaHandleIRQ(EXAMPLE_LPUART, &g_lpuartEdmaHandle);
    SDK_ISR_EXIT_BARRIER;
}

 

Thanks and Regards. 

 

0 Kudos
Reply