hello professors,
I'm new to the msp430FG4619 chip, and now I am doing the project which needs to use uart mode to get the data from the radar and send it to the sd card, but at the same time the collected time should be accurate to the millisecond.
However, the fg4619 chip doesnt have the millisecond part, so I need to use timer module to synchronize with the RTC second part. But after I am facing with more complicated problem, I need to do accurate as much as I can among the uart mode, timer module and SD writing...It means they should be synchronized..I think it is hard to achieve, cause I need to manage the whole structure of the code, but I am a freshman in this area...
After I built the connection, the chip began to receive the data, but there is big gap time between rtc part and millisecond part. Could you help me to give some suggestions to my code in uart mode? because I think the code I wrote in the uart interrupt may not be appropriate, really grateful for your time.
Here is my code in the interrupt:
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
 
  if(UCA0RXBUF==0x52)  //--R(1), 0101 0010 0x52   
    receive_r1[0] = UCA0RXBUF;
  if(UCA0RXBUF == 0xB1)  //--------R(1) --> set 10: --> for the R1 1011 0001, orignally it is 0x31--0011 0010
    cnt_r1 |= 1;  //this should be deleted
  if(cnt_r1)
    {
      if(k1==1)
        {
          receive_r1[1] = UCA0RXBUF & 0x3F;  //--for the T1 1011 0001 -- 0xB1
          k1++;
        }
          t1++;  //jump out for this turn, when t2=3, the value of the BUF will again to send its value
      if(t1>=3)
        receive_r1[k1++] = UCA0RXBUF;
      if(k1 == sizeof (receive_r1) -1)
        {
          P1OUT = P1OUT^BIT0;
          k1=1;
          t1=1;
          cnt_r1 &= ~1;
          count_r1|=1;
        }     
    }
 
  if(UCA0RXBUF==0xD2)  //--R(2), 0101 0010 0x52 --> 1101 0010 0xD2
    receive_r2[0] = UCA0RXBUF & 0x7F;
  if(UCA0RXBUF == 0xB2)  //--------R(2) --> set 10: --> for the R1 1011 0010, orignally it is 0x32--0011 0010
    cnt_r2 |= 1;
  if(cnt_r2)
    {
      if(k2==1)
        {
          receive_r2[1] = UCA0RXBUF & 0x3F;  //--for the T2 1011 0010 -- 0xB2
          k2++;
        }
          t2++;  //jump out for this turn, when t2=3, the value of the BUF will again to send its value
      if(t2>=3)
        receive_r2[k2++] = UCA0RXBUF;
      if(k2 == sizeof (receive_r2) -1)
        {
          P1OUT = P1OUT^BIT6;
          k2=1;
          t2=1;
          cnt_r2 &= ~1;
          count_r2|=1;
        }     
    }
 
  if(UCA0RXBUF==0x54)  //--T(1), 0101 0100 0x54
    receive_t1[0] = UCA0RXBUF;
  if(UCA0RXBUF == 0x71)  //--for the T1 0111 0001, orignally it is 0x31--0011 0010
    cnt_t1 |= 1;
  if(cnt_t1)
    {
      if(k3==1)
        {
          receive_t1[1] = UCA0RXBUF & 0x3F;  //--for the T1 0111 0001 -- 0x71
          k3++;
        }
          t3++;  //jump out for this turn, when t4=3, the value of the BUF will again to send its value
      if(t3>=3)
        receive_t1[k3++] = UCA0RXBUF;
      if(k3 == sizeof (receive_t1) -1)
        {
          P1OUT = P1OUT^BIT6;
          k3=1;
          t3=1;
          cnt_t1 &= ~1;
          sd_tb1 |= 1;
          count_t1|=1;
        }     
    }
 
    
  if(UCA0RXBUF==0xD4)  //--T(2), 0101 0100 0x54 --> 1101 0100 0xD4
    receive_t2[0] = UCA0RXBUF & 0x7F;
  if(UCA0RXBUF == 0x72)  //--for the T2 0111 0010, orignally it is 0x32--0011 0010
    cnt_t2 |= 1;
  if(cnt_t2)
    {
      if(k4==1)
        {
          receive_t2[1] = UCA0RXBUF & 0x3F;  //--for the T2 0111 0010 -- 0x72
          k4++;
        }
          t4++;  //jump out for this turn, when t4=3, the value of the BUF will again to send its value
      if(t4>=3)
        receive_t2[k4++] = UCA0RXBUF;
      if(k4 == sizeof (receive_t2) -1)
        {
          P1OUT = P1OUT^BIT0;
          k4=1;
          t4=1;
          cnt_t2 &= ~1;
          count_t2|=1;
        }     
    }
}
Best Regards
 
				 
		 
					 
                           
				 
				 
				