Problems using UART in interrupt mode with SK3111

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

Problems using UART in interrupt mode with SK3111

2,098 Views
JorgeSans
Contributor II

Hello,

I am having trouble using the UART peripheral with interrupts. The code I am publishing below does not work; nothing is transmitted, and the execution ends up in the error situation: undefined_handler. Could someone indicate what I might be doing incorrectly?

 

/*==================================================================================================
*                                        INCLUDE FILES
==================================================================================================*/
#include "Clock_Ip.h"
#include "Lpuart_Uart_Ip.h"
#include "Lpuart_Uart_Ip_Irq.h"
#include "IntCtrl_Ip.h"
#include "time.h"
#include "../libs/COBSLib/Inc/cobs.h"
/*==================================================================================================
*                                       LOCAL MACROS
==================================================================================================*/
/*==================================================================================================
*                                     IMPORTED FUNCTIONS
==================================================================================================*/
/*==================================================================================================
*                                      GLOBAL VARIABLES
==================================================================================================*/
volatile int exit_code = 0;
/*==================================================================================================
*                                   TSA tables for FreeMASTER
==================================================================================================*/
//#include "config/PMSM_appfreemaster_TSA.h"
 
/*==================================================================================================
*                                    FUNCTIONS DEFINITION
==================================================================================================*/
 
void UART_event_cbk(const uint8 HwInstance, const Lpuart_Uart_Ip_EventType Event, void *UserData)
{
 
}
 
 
 
#include "board.h"
#define MESSAGE_BUFF 50
 
int main(void)
{
    BRD_Init();
    ///////////////////////  MY CODE /////////////////////////////////
    /** UART Driver */
    IntCtrl_Ip_Init(&IntCtrlConfig_0);
    IntCtrl_Ip_EnableIrq(LPUART3_IRQn);
    Lpuart_Uart_Ip_Init(3U, &Lpuart_Uart_Ip_xHwConfigPB_3);
 
    /***********************************************************************************************
    *      Application
    ***********************************************************************************************/
 
    //uint8 message[] = {'H','O','L','A'};
    uint8 message[] = "Hola ABBI como estas?";
    TIM_Init();
    uint32_t lastSendTime = TIM_GetTicks();
    uint32_t sendInterval = 100;
 
uint8_t encodedMessageBuff[MESSAGE_BUFF] = { 0 };
size_t length = strlen((char *)message);
 
volatile Lpuart_Uart_Ip_StatusType lpuartStatus = LPUART_UART_IP_STATUS_ERROR;
 
    while (1)
    {
        uint32_t currentTime = TIM_GetTicks();
 
        if (currentTime - lastSendTime >= sendInterval)
        {
 
        cobs_encode_result result = cobs_encode(encodedMessageBuff, MESSAGE_BUFF, message,
        length + 1);;
        encodedMessageBuff[result.out_len + 1] = 0x00;
 
        lpuartStatus = Lpuart_Uart_Ip_AsyncSend(3U, encodedMessageBuff, result.out_len + 1);
        //lpuartStatus = Lpuart_Uart_Ip_SyncSend(3U, encodedMessageBuff, result.out_len + 1, 5000);
 
            lastSendTime = currentTime;
        }
 
    uint32 remainingBytes;
    do
    {
    lpuartStatus = Lpuart_Uart_Ip_GetTransmitStatus(3U, &remainingBytes);
    } while (LPUART_UART_IP_STATUS_BUSY == lpuartStatus);
 
 
    }
 
    return exit_code;
}

 

0 Kudos
Reply
6 Replies

2,030 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@JorgeSans

This is obviously an RTD version compatibility issue.

The demo I provided to you is based on RTD 2.0.2 and you can refer to it, I don't think there is a big

difference

0 Kudos
Reply

2,055 Views
JorgeSans
Contributor II

JorgeSans_0-1718196185845.png

Not sure if  is relevant but I can nos access this tab. is this normal?

0 Kudos
Reply

2,056 Views
JorgeSans
Contributor II

JorgeSans_0-1718196095388.png

Not sure if this is relevant but I can not access this tab

0 Kudos
Reply

2,062 Views
JorgeSans
Contributor II

Hi @Senlent :

It is not possible to import IntCtrl_Ip_ConfigIrqRouting because I do not know how to enable the following condition. I believe it might require activating a checkbox somewhere in the configuration tool, but I have not been able to locate it.

#if (INT_CTRL_IP_MSCM_SYSTEM_INTERRUPT_ROUTER == STD_ON)

Therefore, when I try to compile my ported application to the S32K311, the following error arises:

D:\GIT\abbi\Debug/../src/main.c:81: undefined reference to `IntCtrl_Ip_ConfigIrqRouting'

 

JorgeSans_0-1718194137346.png

The example you sent cannot be opened with my IDE as shown in the image.

 

Any suggestion about how to solve the issue ?

0 Kudos
Reply

2,097 Views
JorgeSans
Contributor II

I have just forgotten to mention that any suggestions on how to use Reception with interrupts are more than welcome.

0 Kudos
Reply

2,071 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@JorgeSans

Please take a look at the demo in the attachments.

This demo made base on S32K12 and I think there is no much difference between S32K311 and S32K312.

0 Kudos
Reply