Sep 27, 2013
05:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 27, 2013
05:30 AM
Hi,
I'm trying Uart communication into xmc4500. As I'm porting firmware from another microcontroller I'm trying to configure the Uart without FIFO and without DMA.
So I used the Uart001 app from DAVE changing some register settings as follow in order to use UART the "normal way" ie rx interrupt on each received char:
// enable shift buffer empty interrupt
WR_REG(USIC0_CH0->CCR, USIC_CH_CCR_TSIEN_Msk, USIC_CH_CCR_TSIEN_Pos,1);
// shift buffer empty interrupt on SR0
WR_REG(USIC0_CH0->INPR, USIC_CH_INPR_TSINP_Msk, USIC_CH_INPR_TSINP_Pos,0);
//Receive event event is enabled.
WR_REG(USIC0_CH0->CCR, USIC_CH_CCR_RIEN_Msk, USIC_CH_CCR_RIEN_Pos,1);
//Alternative receive event event is enabled.
WR_REG(USIC0_CH0->CCR, USIC_CH_CCR_AIEN_Msk, USIC_CH_CCR_AIEN_Pos,1);
//Interrupt node 1 is selected for Receive event
WR_REG(USIC0_CH0->INPR, USIC_CH_INPR_RINP_Msk, USIC_CH_INPR_RINP_Pos,1);
//Interrupt node 1 is selected for Alternative receive event
WR_REG(USIC0_CH0->INPR, USIC_CH_INPR_AINP_Msk, USIC_CH_INPR_AINP_Pos,1);
Uart settings are 57600 8 N 1 ( Uart_Conf settings taken from DAVE)
I have no other peripheral active.
The problem is that inside rx interrupt, sometimes I get a wrong character. I mean, I'm sending a repetitive pattern of 6 chars from PC ( +++AT[CR] ) every 100ms. After some good receptions ( random number ) where all characters are received well, a wrong vharacter is received. I monitored the situation through oscilloscope: incoming chars are good. From xmc tx line I see that if I transmit something the timings are correct.
Inside interrupt I read received chars as follow:
if(UART001_GetFlagStatus(&UART001_Handle0_CH0,UART001_RECV_IND_FLAG) == UART001_SET)
{
ch = UART001_Handle0_CH0.UartRegs->RBUF;
if( ( ch == (short)'+' ) || ( ch == (short)'A' ) || ( ch == (short)'T' ) || ( ch == 0x0d ) ) {
UART001_Handle0_CH0.UartRegs->TBUF[0] = ch;
P5_1_toggle();
}
UART001_ClearFlag(&UART001_Handle0_CH0,UART001_FIFO_STD_RECV_BUF_FLAG);
}
}
Does anybody has any idea why sometimes I get a wrong char? Am I missing something?
Thanks.
Frank
I'm trying Uart communication into xmc4500. As I'm porting firmware from another microcontroller I'm trying to configure the Uart without FIFO and without DMA.
So I used the Uart001 app from DAVE changing some register settings as follow in order to use UART the "normal way" ie rx interrupt on each received char:
// enable shift buffer empty interrupt
WR_REG(USIC0_CH0->CCR, USIC_CH_CCR_TSIEN_Msk, USIC_CH_CCR_TSIEN_Pos,1);
// shift buffer empty interrupt on SR0
WR_REG(USIC0_CH0->INPR, USIC_CH_INPR_TSINP_Msk, USIC_CH_INPR_TSINP_Pos,0);
//Receive event event is enabled.
WR_REG(USIC0_CH0->CCR, USIC_CH_CCR_RIEN_Msk, USIC_CH_CCR_RIEN_Pos,1);
//Alternative receive event event is enabled.
WR_REG(USIC0_CH0->CCR, USIC_CH_CCR_AIEN_Msk, USIC_CH_CCR_AIEN_Pos,1);
//Interrupt node 1 is selected for Receive event
WR_REG(USIC0_CH0->INPR, USIC_CH_INPR_RINP_Msk, USIC_CH_INPR_RINP_Pos,1);
//Interrupt node 1 is selected for Alternative receive event
WR_REG(USIC0_CH0->INPR, USIC_CH_INPR_AINP_Msk, USIC_CH_INPR_AINP_Pos,1);
Uart settings are 57600 8 N 1 ( Uart_Conf settings taken from DAVE)
I have no other peripheral active.
The problem is that inside rx interrupt, sometimes I get a wrong character. I mean, I'm sending a repetitive pattern of 6 chars from PC ( +++AT[CR] ) every 100ms. After some good receptions ( random number ) where all characters are received well, a wrong vharacter is received. I monitored the situation through oscilloscope: incoming chars are good. From xmc tx line I see that if I transmit something the timings are correct.
Inside interrupt I read received chars as follow:
if(UART001_GetFlagStatus(&UART001_Handle0_CH0,UART001_RECV_IND_FLAG) == UART001_SET)
{
ch = UART001_Handle0_CH0.UartRegs->RBUF;
if( ( ch == (short)'+' ) || ( ch == (short)'A' ) || ( ch == (short)'T' ) || ( ch == 0x0d ) ) {
UART001_Handle0_CH0.UartRegs->TBUF[0] = ch;
P5_1_toggle();
}
UART001_ClearFlag(&UART001_Handle0_CH0,UART001_FIFO_STD_RECV_BUF_FLAG);
}
}
Does anybody has any idea why sometimes I get a wrong char? Am I missing something?
Thanks.
Frank
- Tags:
- IFX
2 Replies
Sep 27, 2013
07:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 27, 2013
07:15 AM
Hi again,
it seems to me that the problem disappears if I remove the echo from the rx interrupt:
UART001_Handle0_CH0.UartRegs->TBUF[0] = ch;
Can a single channel of a Usic module be used in full duplex mode? Or have I tu use two different channels if I want full duplex?
Thanks
Frank
it seems to me that the problem disappears if I remove the echo from the rx interrupt:
UART001_Handle0_CH0.UartRegs->TBUF[0] = ch;
Can a single channel of a Usic module be used in full duplex mode? Or have I tu use two different channels if I want full duplex?
Thanks
Frank
Jun 01, 2022
08:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 01, 2022
08:07 AM
9 years later and no one answer this guy....