Not applicable
Feb 08, 2017
08:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 08, 2017
08:10 AM
hello
is there any code snippet available for auto baudrate detection function for the XMC1100?
regards
enzo
is there any code snippet available for auto baudrate detection function for the XMC1100?
regards
enzo
- Tags:
- IFX
2 Replies
Feb 15, 2017
09:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 15, 2017
09:48 AM
Hi,
You can either try with counter register in the USIC or your could even use the capture functionality of the CCUx.
Below is the code using the capture register in the USICx
Regards,
Jesus
You can either try with counter register in the USIC or your could even use the capture functionality of the CCUx.
Below is the code using the capture register in the USICx
#include
#include
#define UART_TX P1_5
#define UART_RX P1_4
__STATIC_INLINE uint32_t XMC_USIC_CH_GetCaptureTimerValue(const XMC_USIC_CH_t *const channel)
{
return channel->CMTR;
}
__STATIC_INLINE void XMC_USIC_CH_SetFractionalDivider(XMC_USIC_CH_t *const channel, const XMC_USIC_CH_BRG_CLOCK_DIVIDER_MODE_t mode, const uint16_t step)
{
channel->FDR = mode | step;
}
int main(void)
{
volatile uint32_t baudrate;
XMC_USIC_CH_Enable(XMC_UART0_CH0);
XMC_GPIO_SetMode(UART_RX, XMC_GPIO_MODE_INPUT_TRISTATE);
XMC_USIC_CH_SetInputSource(XMC_UART0_CH0, XMC_UART_CH_INPUT_RXD, USIC0_C0_DX0_P1_4);
// Set counter frequency to 1MHz
XMC_USIC_CH_SetFractionalDivider(XMC_UART0_CH0, XMC_USIC_CH_BRG_CLOCK_DIVIDER_MODE_NORMAL, 1023 - (uint32_t)(SystemCoreClock / 1000000));
XMC_USIC_CH_EnableTimeMeasurement(XMC_UART0_CH0);
XMC_USIC_CH_SetInputTriggerCombinationMode(XMC_UART0_CH0, XMC_UART_CH_INPUT_RXD, XMC_USIC_CH_INPUT_COMBINATION_MODE_FALLING_EDGE);
while ((XMC_UART_CH_GetStatusFlag(XMC_UART0_CH0) & XMC_UART_CH_STATUS_FLAG_TRANSMIT_SHIFT_INDICATION) == 0);
XMC_UART_CH_ClearStatusFlag(XMC_UART0_CH0, XMC_UART_CH_STATUS_FLAG_TRANSMIT_SHIFT_INDICATION);
XMC_USIC_CH_SetInputTriggerCombinationMode(XMC_UART0_CH0, XMC_UART_CH_INPUT_RXD, XMC_USIC_CH_INPUT_COMBINATION_MODE_RISING_EDGE);
while ((XMC_UART_CH_GetStatusFlag(XMC_UART0_CH0) & XMC_UART_CH_STATUS_FLAG_TRANSMIT_SHIFT_INDICATION) == 0);
// The host will send 0x00, the pulse length will be 9 * (1 / baudrate)
baudrate = (9 * 1E6) / XMC_USIC_CH_GetCaptureTimerValue(XMC_UART0_CH0);
/* Placeholder for user application code. The while loop below can be replaced with user application code. */
while(1U)
{
}
}
Regards,
Jesus
Not applicable
Feb 16, 2017
02:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 16, 2017
02:15 PM
thank you
regards
enzo
regards
enzo