Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hello everyone!

I'm trying to Enable interrupts for reciveing data from UART0 on XMC 2 GO board. Data sending works ok but I can't enable interrupts for incoming data. Can you help me with the cosde? I'm using Atollic True Studio and CMSIS Library pack.


#include "xmc_uart.h"
#include "xmc_gpio.h"
#include "xmc_scu.h"

#include
#include
#include

volatile uint32_t timer1;



void uart_putchar (char data)
{
XMC_UART_CH_Transmit(XMC_UART0_CH0 , data);
}


void uart_putS (char * data)
{
char znak = 0;
while( (znak = *data++) ) uart_putchar(znak);
}

void SysTick_Handler (void)
{
if(timer1) timer1--;
}

void USIC0_0_IRQHandler (void)
{

}

/* main function */
int main(void)
{
// SystemInit();
// SystemCoreClockUpdate();

XMC_GPIO_CONFIG_t TX_pin =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT6,
.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH
};

XMC_GPIO_CONFIG_t RX_pin =
{
.mode = XMC_GPIO_MODE_INPUT_TRISTATE,
.input_hysteresis = XMC_GPIO_INPUT_HYSTERESIS_STANDARD,
};
XMC_GPIO_CONFIG_t LED1 =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW
};
XMC_GPIO_CONFIG_t LED2 =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW
};

XMC_UART_CH_CONFIG_t UART_board =
{
.baudrate = 9600UL,
.data_bits = 8UL,
.stop_bits = 1UL,
.parity_mode = XMC_USIC_CH_PARITY_MODE_NONE,

};



XMC_USIC_CH_t *uart_0 = XMC_UART0_CH0;



XMC_UART_CH_Init(uart_0, &UART_board);
XMC_UART_CH_SetInputSource(uart_0, XMC_UART_CH_INPUT_RXD1, USIC0_C0_DX3_P2_2);
XMC_UART_CH_Start(uart_0);
USIC0_CH0->INPR &= ~(USIC_CH_INPR_RINP_Msk);
XMC_UART_CH_ClearStatusFlag(uart_0, XMC_UART_CH_STATUS_FLAG_RECEIVE_INDICATION);
XMC_UART_CH_EnableEvent(uart_0, XMC_UART_CH_EVENT_STANDARD_RECEIVE);
NVIC_ClearPendingIRQ(USIC0_0_IRQn);
NVIC_EnableIRQ(USIC0_0_IRQn);


XMC_GPIO_Init( P2_1, &TX_pin );
XMC_GPIO_Init( P2_2, &RX_pin );
XMC_GPIO_EnableDigitalInput(P2_2);
XMC_GPIO_Init( P1_0, &LED1 );
XMC_GPIO_Init( P1_1, &LED2 );

SysTick_Config(SystemCoreClock/1000);



uint8_t licznik = 1;
char itoa_buf[10];
/* Infinite loop */
while (1)
{

if(!timer1)
{


timer1 = 500;
XMC_GPIO_ToggleOutput(P1_0);
XMC_GPIO_ToggleOutput(P1_1);
uart_putS(itoa(licznik++, itoa_buf, 10));
uart_putS("\r\n");
}

}

}


0 Likes
0 Replies