Dear, Infenion.
I'm haneul yun.
I used Distance2Go and i try to uart communication.
i am trying to configure UART transmission for an Distance2Go.
and i finished setting of the UART Pins in order to use the UART as belows.
#define UART_TX P0_1
#define UART_RX P0_0
And i tried to transfer data using the UART_TX and it's successful.
But there are problems about sending the data transmit.
I don't see the ascii data in my serial data monitoring programs.
i only see the incorrented hex data compare of original data.
Also, When I checked the signal with an oscilloscope the bits came out LSB.
ex) i send the 0x3A(0x00111010), the signal with an oscilloscope is 0x5C(0x0101 1100)
I guess this problem occurs the LSB setting and in order to solve this problems i have to set as the MSB when the data is transmit.
how can i set the MSB setting in UART?
Could you give me an example code or information about MSB/LSB setting?
my code is as belows.
#include "uart.h"
#include "xmc_uart.h"
/* Initialization structure for both USIC0_CH0 and USIC0_CH1 channels */
XMC_UART_CH_CONFIG_t uart_config =
{
.data_bits = 8U,
.stop_bits = 1U,
.baudrate = 9600, //Baudrate
};
XMC_GPIO_CONFIG_t uart_tx =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2,
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW,
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_WEAK
};
XMC_GPIO_CONFIG_t uart_rx =
{
.mode = XMC_GPIO_MODE_INPUT_TRISTATE
};
/* Transmit handling IRQ */
void USIC0_0_IRQHandler(void)
{
}
const uint8_t message[] = "Hello radar!!\n";
void uart_init()
{
XMC_UART_CH_Init(XMC_UART1_CH1, &uart_config);
XMC_UART_CH_Start(XMC_UART1_CH1);
XMC_GPIO_Init(UART_TX, &uart_tx);
// XMC_USIC_CH_SetShiftDirection(XMC_UART1_CH1, XMC_USIC_CH_SHIFT_DIRECTION_MSB_FIRST);
// XMC_USIC_CH_SHIFT_DIRECTION_LSB_FIRST /**< Shift LSB first. The first data bit of a data word is located at bit position 0. */
// XMC_USIC_CH_SHIFT_DIRECTION_MSB_FIRST /**< Shift MSB first. The first data bit of a data word is located at the bit position given by the configured word length. */
send_uart_data("Uart/n",sizeof("Uart/n"));
XMC_UART_CH_Transmit(XMC_UART1_CH1, 0x60);
}
void send_uart_data(unsigned char *data, uint32_t length)
{
uint32_t index;
for (index = 0; index < length; index++)
{
XMC_UART_CH_Transmit(XMC_UART1_CH1, data[index]);
}
}
I'm haneul yun.
I used Distance2Go and i try to uart communication.
i am trying to configure UART transmission for an Distance2Go.
and i finished setting of the UART Pins in order to use the UART as belows.
#define UART_TX P0_1
#define UART_RX P0_0
And i tried to transfer data using the UART_TX and it's successful.
But there are problems about sending the data transmit.
I don't see the ascii data in my serial data monitoring programs.
i only see the incorrented hex data compare of original data.
Also, When I checked the signal with an oscilloscope the bits came out LSB.
ex) i send the 0x3A(0x00111010), the signal with an oscilloscope is 0x5C(0x0101 1100)
I guess this problem occurs the LSB setting and in order to solve this problems i have to set as the MSB when the data is transmit.
how can i set the MSB setting in UART?
Could you give me an example code or information about MSB/LSB setting?
my code is as belows.
#include "uart.h"
#include "xmc_uart.h"
/* Initialization structure for both USIC0_CH0 and USIC0_CH1 channels */
XMC_UART_CH_CONFIG_t uart_config =
{
.data_bits = 8U,
.stop_bits = 1U,
.baudrate = 9600, //Baudrate
};
XMC_GPIO_CONFIG_t uart_tx =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2,
.output_level = XMC_GPIO_OUTPUT_LEVEL_LOW,
.output_strength = XMC_GPIO_OUTPUT_STRENGTH_WEAK
};
XMC_GPIO_CONFIG_t uart_rx =
{
.mode = XMC_GPIO_MODE_INPUT_TRISTATE
};
/* Transmit handling IRQ */
void USIC0_0_IRQHandler(void)
{
}
const uint8_t message[] = "Hello radar!!\n";
void uart_init()
{
XMC_UART_CH_Init(XMC_UART1_CH1, &uart_config);
XMC_UART_CH_Start(XMC_UART1_CH1);
XMC_GPIO_Init(UART_TX, &uart_tx);
// XMC_USIC_CH_SetShiftDirection(XMC_UART1_CH1, XMC_USIC_CH_SHIFT_DIRECTION_MSB_FIRST);
// XMC_USIC_CH_SHIFT_DIRECTION_LSB_FIRST /**< Shift LSB first. The first data bit of a data word is located at bit position 0. */
// XMC_USIC_CH_SHIFT_DIRECTION_MSB_FIRST /**< Shift MSB first. The first data bit of a data word is located at the bit position given by the configured word length. */
send_uart_data("Uart/n",sizeof("Uart/n"));
XMC_UART_CH_Transmit(XMC_UART1_CH1, 0x60);
}
void send_uart_data(unsigned char *data, uint32_t length)
{
uint32_t index;
for (index = 0; index < length; index++)
{
XMC_UART_CH_Transmit(XMC_UART1_CH1, data[index]);
}
}