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.

CC2538 UART communication

Other Parts Discussed in Thread: CC2538, CC2530

Hi,all,

My project requires using two UART port(uart0 and uart1) at same time,

I am using zstack 1.2.0 on cc2538, some people told me that I have to set UART0 to use DMA and another to use ISR, otherwise it will not work.I tried to di it, but I can't find hal_dma.h in zstack 1.2.0,  so here is the question:

Dose zstack 1.2.0 support UART_DMA? If it dose, how can I do it? If not , is there another way to implement using two UART port at same time on CC2538?

Thanks a lot

Xu

  • Unfortunately you where given incorrect information. CC2538 UART driver only supports UART ISR. It is CC2530 that has support for ISR or DMA.

    What I would recommend is this:

    1. rename _hal_uart_isr.c to hal_uart0_isr.c
    2. rename hal_uart0_isr.c API's from HalUart...Isr... to HalUart0...Isr...
    2. copy _hal_uart0_isr.c to hal_uart1_isr.c and rename API's to HalUart1...Isr...
    3. remap _hal_uart1_isr.c to use the other UART module on the CC2538. Mostly this will be changing:

    #define HAL_UART_PORT UART1_BASE
    #define HAL_UART_SYS_CTRL SYS_CTRL_PERIPH_UART1
    #define HAL_UART_INT_CTRL INT_UART1
    #define HalUartISR interrupt_uart1

    to use UART0 and interrupt_uart0.

    Then changing the Pin mapping in:

    void HalUARTInitIsr(void)
    {
    SysCtrlPeripheralEnable(HAL_UART_SYS_CTRL);

    /* Setup PB0 as UART_CTS, PD3 as UART_RTS
    * PA1 as UART_TX and PA0 as UART_RX
    */
    IOCPinConfigPeriphOutput(GPIO_A_BASE, GPIO_PIN_1, IOC_MUX_OUT_SEL_UART1_TXD);
    IOCPinConfigPeriphInput(GPIO_A_BASE, GPIO_PIN_0, IOC_UARTRXD_UART1);
    GPIOPinTypeUARTInput(GPIO_A_BASE, GPIO_PIN_0);
    GPIOPinTypeUARTOutput(GPIO_A_BASE, GPIO_PIN_1);
    recRst();

    }

    uint8 HalUARTOpenIsr(uint8 port, halUARTCfg_t *config)
    {
    ...
    if(config->flowControl)
    {
    IOCPinConfigPeriphOutput(GPIO_D_BASE, GPIO_PIN_3, IOC_MUX_OUT_SEL_UART1_RTS);
    GPIOPinTypeUARTOutput(GPIO_D_BASE, GPIO_PIN_3);
    IOCPinConfigPeriphInput(GPIO_B_BASE, GPIO_PIN_0, IOC_UARTCTS_UART1);
    GPIOPinTypeUARTInput(GPIO_B_BASE, GPIO_PIN_0);
    }
    ...
    }

    search for any more instances of UART1 and take care of that.

    4. In hal_uart.c #include hal_uart0_isr.c and hal_uart1_isr.c (removing hal_uart_isr.c). Change the HalUart...Isr calls to HalUart0...Isr or HalUart1...Isr depending on port parameter. In HalUARTPoll where there is no port parameter, call both HalUart0...Isr and HalUart1...Isr.

    I have not tried this, so look out for anything I missed.

    A neater solution may be to combine hal_uart0_isr.c and hal_uart1_isr.c back into a signle file but you can do this once above is working.

    Regards,
    TC.
  • The features of CC2538 shows it has 2xUART, why can't we use it directly?
  • "The features of CC2538 shows it has 2xUART, why can't we use it directly?"

    I'm confused, why do you think it can not be used? I explained in great detail how this can be done.

    Unfortunately the SW was developed in a way to demonstrate how the UART to the host interface can be configured for ISR OR DMA. We have no use case or HW to test 2 simultaneous UART connections.

    Regards,
    TC.
  • how can I communication CC2538 with the CPU by UART ?
  • You can refer to UART example in CC2538 Foundation Firmware.

  • Hi YiKai Chen:
    Even if this problem is answer one years ago. But I encountered the same problem when use CC2538 with two UART0 and UART1 simultaneously,reference the TopCat gave recommended, the problem is that,peripheral device send 32bytes data to UART0 200ms period, the system will crash when Read the UART0,i guarantee the source code is correct.
    I test the UART1 with same source code, the system is all right,every 32bytes data can be received by callback function.What's differents UART0 and UART1 in CC2538 cortex-M3 core device? Only UART1 peripheral integrated FIFO buffer,UART0 is not integrated the FIFO buffer?