This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
i implement UART on USCI_A0 and when i send a file from an hyperterminal on a PC at 115200Kb/s i miss one char every 2 char :
For exemple if PC sends 1,2,3,4,5,6,7.... i receive 1,3,5,7
I have the same problem at 9600b/s
I have the same problem if i disable timer interrupt (no other IT may take over the CPU)
There is no error flag set in UCA0STAT
Here is my UART initialization :
=====================
UCA0CTL1 |= UCSSEL_2; // SMCLK
//Baud rate divider with 1MHz = 1MHz/115200 = ~8.7
UCA0BR0 = 8; // 1MHz 115200
UCA0BR1 = 0; // 1MHz 115200
//In UCA0MCTL: UCBRSx =round( ( 8,7 – INT(8,7) ) × 8 ) = round(0.7*8) = 05
UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
Here is my UART initialization :
=====================
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
//if ( UCOE & UCA0STAT) while(1) {;}
//if ( UCRXERR & UCA0STAT) while(1) {;}
static int compteur=0;
compteur++;
CVM_RXFIFO[CVM_RXFIFOFIFOWriteIndex]=UCA0RXBUF;
CVM_RXFIFOFIFOWriteIndex=(CVM_RXFIFOFIFOWriteIndex+1)%CVM_RX_BUFFER_SIZE;
// P1OUT ^= 0x01;
}
Here is the clock initialization
=======================
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
MAIN_T_Error();
while(1); // If calibration constants erased
}
//use calibration 1MHz for MCLK: Master clock and SMCLK: Sub-main clock. SMCLK is selected as DCOCLK
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
Have you any idea of what can happen ?
Best regards
The UART init looks okay, and the baudrate seems to be good too (else you wouldn't receive anything).
you didn't post the definitions for CVM_RXFIFO and teh write index. And how you read the FIFO. I suspect the logic for the FIFO write/read synchronization.
Are the buffer poitners declared volatiole (else the main loop possibly won't recognize the changes made in the ISR).
What's this? Did you check it for the total amount of bytes received? I bet it will tell the right number.trichet christophe said:static int compteur=0;
compteur++;
**Attention** This is a public forum