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;
}