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.

求助,cc430f5137接受数据问题

Other Parts Discussed in Thread: CC1101

两块板,无线通信成功(依据是CRC校验OK点亮LED),现在想把接收到的数据取出来发送到串口,串口部分带有自动回显,应该是没有问题的,

问题是,A板从串口接收数据通过无线发送到B板的时候,输入的是6个字节的“012345”,输出的是112个字节,而且其中看不到 30 31 32 33 34 35,

我想问,我应该怎么操作,才能取出想要的数据?部分代码如下。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*******************************************************************************
**接收中断处理
******************************************************************************/
#pragma vector=CC1101_VECTOR
__interrupt void CC1101_ISR(void)
{
  switch(__even_in_range(RF1AIV,32))        // Prioritizing Radio Core Interrupt
  {
    case  0: break;                         // No RF core interrupt pending                                           
    case  2: break;                         // RFIFG0
    case  4: break;                         // RFIFG1
    case  6: break;                         // RFIFG2
    case  8: break;                         // RFIFG3
    case 10: break;                         // RFIFG4
    case 12: break;                         // RFIFG5
    case 14: break;                         // RFIFG6         
    case 16: break;                         // RFIFG7
    case 18: break;                         // RFIFG8
    case 20:                                // RFIFG9
      if(receiving)             // 接收触发的中断
      {
        // Read the length byte from the FIFO      
        RxBufferLength = ReadSingleReg( RXBYTES );              
        ReadBurstReg(RF_RXFIFORD, RxBuffer, RxBufferLength);
        __no_operation();         
        // Check the CRC results
        if(RxBuffer[CRC_LQI_IDX] & CRC_OK)
        {                    
          delayms(10);
          PutString(RxBuffer);
          
        }
      }
      else if(transmitting)         // 发送触发的中断
      {
        RF1AIE &= ~BIT9;                    // Disable TX end-of-packet interrupt                        
        transmitting = 0;
      }
      else while(1);
      ResetRadioCore();
      InitRadio();
      Strobe( RF_SRX );
      // trap
      break;
    case 22: break;                         // RFIFG10
    case 24: break;                         // RFIFG11
    case 26: break;                         // RFIFG12
    case 28: break;                         // RFIFG13
    case 30: break;                         // RFIFG14
    case 32: break;                         // RFIFG15
  
  __bic_SR_register_on_exit(LPM3_bits);    
}
/*******************************************************************************
**串口中断处理
*******************************************************************************/
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
  switch(__even_in_range(UCA0IV,4))
  {
  case 0:break;                             // Vector 0 - no interrupt
  case 2:                                   // Vector 2 - RXIFG
    while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
    UCA0TXBUF = UCA0RXBUF;                  // TX -> RXed character
     ReceiveOff();
     receiving = 0;
     Transmit( (unsigned char*)UCA0TXBUF,sizeof UCA0TXBUF);
     transmitting = 1;
    break;
  case 4:break;                             // Vector 4 - TXIFG
  default: break;
  }
}
  • Xiangkun,

    有两种办法你可以试试,第一是直接测试UART部分的程序,不考虑RF部分数据的收发。

    第二个是在CC1101的接收中断里面直接调用UART的发送程序试试,不采用UART发送中断来发送数据,然后查看是否数据正确。

    你的程序不是很完整,UART初始化的部分没有看到。

    谢谢

  • uchar *TxData="串口初始化完毕\n";
    
    
    
    void InitUART()
    {
    
      PMAPPWD = 0x02D52;                        // Get write-access to port mapping regs  
      P1MAP5 = PM_UCA0RXD;                      // Map UCA0RXD output to P1.5 
      P1MAP6 = PM_UCA0TXD;                      // Map UCA0TXD output to P1.6 
      PMAPPWD = 0;                              // Lock port mapping registers 
      
      P1DIR |= BIT6;                            // Set P1.6 as TX output
      P1SEL |= BIT5 + BIT6;                     // Select P1.5 & P1.6 to UART function
      
      UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
      UCA0CTL1 |= UCSSEL_1;                     // SMCLK
      UCA0BR0 = 3;                              // 32.768KHz 9600 (see User's Guide)
      UCA0BR1 = 0;                              // 32.768KHz 9600
      UCA0MCTL |= UCBRS_3 + UCBRF_0;            // Modulation UCBRSx=1, UCBRFx=0
      UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
      UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
      PutString(TxData);
     // __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
    //  __no_operation();                         // For debugger
    }
    

    串口 之前调试过是好的,无线是看CRC标志,应该也没问题,现在6个字节能收到3个正确的了,试试把数据变短一点,速度快一点看看