Other Parts Discussed in Thread: MSP430F5510
Tool/software:
Hi Everyone,
I'm trying to implement a serial communication via UART between my MSP430F5358 chip and another microcontroller (Atmel AtxMega32e5). I set a receive interrupt on Uart0 in order to receive messages from the other micro. The unit of measurement of the message is the byte, that is, the interrupt is triggered when a byte arrives on the Uart_Rx pin. Which the serial works with a baud rate of 115.2 KHz (the same that the Atmel serial has set) -> each bit lasts about 8.6us.
The problem I have is that when I receive "long" messages the serial seems to overrun, unable to keep up with the bytes that arrive (which are gradually saved in a circular buffer). The final part of the message is always dirty and this means that the entire implemented message parsing protocol does not work correctly, returning an error on the framing of the received message.
Example (short message):
Message actually received (viewed with the oscilloscope):
0x55, 0x02, 0x7F (message Tag), 0x03
Message read in dubug on UART0:
0x55, 0x02, 0x7F (message Tag), 0x03 (OK!!)
Example (long message):
Message actually received (viewed with the oscilloscope):
0x55, 0x02, 0xB0(message Tag), 0x00 , 0x00, 0x00, 0x00, 0x03
Message read in dubug on UART0:
0x55, 0x02, 0xB0(message Tag), 0x00 , 0x00 (3 bytes missing!!)
At the moment I have verified the following things:
- the baud rate is precise and the same for both serial ports (equal to 115.2KHz).;
- the interrupt function in reception responds and works correctly, resulting in a correct timing with each single incoming byte (verified by inserting a toggle of a GPIO pin at each execution of the interrupt);
- there are no spurious interrupts that could cause problems in the reception timing;
This is the function for UART setting:
void InitUartMan(void)
{
UCA0CTL1 |= UCSWRST; // disable USCI module, enable settings change
UCA0CTL0 &= ~UC7BIT; // 8-bit data
UCA0CTL1 |= UCSSEL__ACLK; // UCLK = ACLK
UCA0BRW_L = BAUD115; // 115200 bps baudrate @ ACLK = 4096000Hz.
UCA0BRW_H = BAUD0;
UCA0MCTL = 0x00;
UCA0CTL1 &= ~(UCSWRST); // enable USCI module, disable settings change
UCA0IE |= UCRXIE; // receive interrupt enable, transmit interrupt disable
AckCmdMan = 0; // init command status
}
and this is the interrupt function written for the reception on UART0:
#pragma vector=USCI_A0_VECTOR
__interrupt void UartRx0(void)
{
char rxchar;
rxchar = UCA0RXBUF; // save received byte.
*InpkcqMan.wr++ = rxchar; // Circular buffering of input data.
if(InpkcqMan.wr>InpkcqMan.top)
InpkcqMan.wr = InpkcqMan.bot;
}
If anyone has any advice to give me to solve this problem I would be grateful!
Many Thanks!!
Matteo