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.

How to control the RS485 data transceiver direction

Other Parts Discussed in Thread: CC2530

Dear friends,

We now use ZStack-CC2530-2.3.0-1.4.0, and need CC2530 send and receive data through RS485. if we set the data direction as CC2530 ->RS485 and don't change it, the data send is right. and if we set the direction is RS485 ->CC2530 and don't change it, the data receive also right.

But, when CC2530 need send data to RS485, we set the disrection (CC2530 ->RS485) befor HalUARTWrite(HAL_UART_PORT_0, pData, len); and set the  contrary direction (RS485 ->CC2530) when UART send out event == HAL_UART_TX_EMPTY. we do it, but the dara error is very higher.

Please help me. how to control the RS485 data transceiver direction

 

BestRegard.Yihua

  • hi,have you been succeed in this problem?i met the problem too.please contact me,or we could discuss about it!

  • Dear Albert,

    We have not solve it till now, do you have some good method.

    BestRegard.Yihua

  • 将程序改为ISR模式,(dma模式,不好控制)

    具体修改TX 中断处理函数,如下:

    #if (HAL_UART_ISR == 1)
    HAL_ISR_FUNCTION( halUart0TxIsr, UTX0_VECTOR )
    #else
    HAL_ISR_FUNCTION( halUart1TxIsr, UTX1_VECTOR )
    #endif
    #endif
    {
     
      if (isrCfg.txHead == isrCfg.txTail)
      {
        IEN2 &= ~UTXxIE;  
        isrCfg.txMT = 1;
        MicroWait(1500);
        U1CSR|=0x40;
        P1_5=0;

      }
      else
      {
        U1CSR&=~0x40;
        P1_5=1;
        UTXxIF = 0;
        UxDBUF = isrCfg.txBuf[isrCfg.txHead++];

        if (isrCfg.txHead >= HAL_UART_ISR_TX_MAX)
        {
          isrCfg.txHead = 0;
        }
      }
      }

     

    其中P1_5为控制引脚。
    这样做后,可以正常通信!