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.

Uart CC2431

Other Parts Discussed in Thread: Z-STACK, CC2431, CC2430

Hi!

My question: where in the code for Z-stack 1.4.3 do you change what pins the rx and the tx are associated with?

Thank you!

Best Regards

Therese

  • Hi,

    There are 2 USART modules on the CC2430/31. You can see in the datasheet for CC2430 (Same as for CC2431) the different I/O pin alternatives for UART in table 40 of the datasheet "Peripheral I/O pin mapping".

    In Z-stack you can select either HAL_UART_PORT_0 or HAL_UART_PORT_1 as argument to the function HalUARTOpen() to select which UART you want to use. The I/O pin alternatives for the two different USARTS are configured in the function HalUARTInit(). UART0 is set to port P0 and UART1 to port P1 by default, but you can change this in that function if your board is configured differently.  

    Also you can have a look at the SerialApp which is included with Z-stack for an example how to use the UART.

    Regards,

    Bjørn

  • Thanks for you quick reply!

    When you have set the Uart to either port 0 or port 1, how do you then know what pins the rx and tx should be connected to. For example P1_0 and P1_1? Where do you configure that?

    Best Regards

    Therese

  •  

    Hi,

    This can be seen it in the function HalUARTInit(), and comparing it with table 40 in the datasheet for CC2430. 

    By default if your project has defined the compiler option HAL_UART it enables UART 1. You can see in this function that it will then set up UART1 to I/O location P1. So this corresponds to USART1 UART alternative 2 in table 40:  RX: P1.7, TX: P1.6.

    The define that enables UART1 by default when HAL_UART is set in the project, is defined in the file hal_board_cfg.h. So you can can change these lines in hal_board_cfg.h if you want to enable UART0 instead:

    #if HAL_UART
      #define HAL_UART_0_ENABLE  FALSE
      #define HAL_UART_1_ENABLE  TRUE

    Regards,

    Bjørn