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.

Transparent code of BLE CC256X on Tiva TM4C123G

Hi!

Can any one correct me or help me? what wrong with the UART1 initialization, code gets hanged when call the function

UARTStdioConfig(1, 115200, 16000000);. I think this function is default uses UART0 only.
 Pls help me to setup the complete UART1 interface

uC: TM4C123H6PGE

Keil5,

Interface: UART0 and UART1

//***************************************************************************************
// This example demonstrates how to send a string of data to the UART.
//***************************************************************************************

   /* BLE Device connections                            */
     /* Interface : UART1.                                   */
   /*                                                                   */
   /* Function     Port/Pin                                   */
   /* --------     --------                                         */
   /*   RX           PC4                                          */
   /*   TX           PC5                                          */
   /*   RTS          PF0                                        */
   /*   CTS          PF1                                        */
   /*  RESET         PF2                                      */
   /*                                                                   */
//*****************************************************************************

int main(void)
{
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    
    ROM_FPULazyStackingEnable();
    
    // Set the clocking to run directly from the crystal.
    
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);
   
    // Enable the GPIO Peripheral used by the UART0.
 
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    // Enable UART0

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
 
    // Configure GPIO Pins for UART mode.

    ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
    ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    // Use the internal 16MHz oscillator as the UART clock source.
 
    ROM_UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

    // Initialize the UART0 for console I/O.
 
    UARTStdioConfig(0, 115200, 16000000);
        
        // Enable the UART interrupt.
 
    ROM_IntEnable(INT_UART0);
    ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
        ROM_IntMasterEnable();
        
    UARTprintf("\nBLE Command\n");
            
        
        /* Configure the UART module and the GPIO pins used by the     */
    /* UART.                                                       */
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);        // Define Rx & Tx
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);         // Define RTS & CTS   
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);        // Select UART1

        ROM_GPIOPinConfigure(GPIO_PC4_U1RX);                                // UART1 : PORTC, PIN4_RX
    ROM_GPIOPinConfigure(GPIO_PC5_U1TX);                                // UART1 : PORTC, PIN5_TX
    ROM_GPIOPinConfigure(GPIO_PF0_U1RTS);                                // UART1 : PORTF, PIN0_RTS
    ROM_GPIOPinConfigure(GPIO_PF1_U1CTS);                                // UART1 : PORTF, PIN1_CTS

    ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    ROM_GPIOPinTypeUART(GPIO_PORTF_BASE, GPIO_PIN_0);
    ROM_GPIOPinTypeUART(GPIO_PORTF_BASE, GPIO_PIN_1);

    UARTFlowControlSet(UART1_BASE, UART_FLOWCONTROL_RX | UART_FLOWCONTROL_TX);        
        UARTStdioConfig(1, 115200, 16000000);
//        UARTStdioInitExpClk(1, 115200);
        
        ROM_IntEnable(INT_UART1);
    ROM_UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);
        ROM_IntMasterEnable();
        
    while(1)
        {
    //        UARTwrite(Rx_pcCmdBuf1, sizeof(Rx_pcCmdBuf1));                
            
        }
}

Thanks in advance

Pramod

  • Hello Pramod,

    First of all the PF0 pin is a locked pin. You have to unlock and commit it as given in the post below

    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/284566.aspx

    Second, the UARTStdioConfig does work for UART-1. In the code post shown, the UART-1 Clock is not 16MHz but System Clock of 4MHz. If you want to use 16MHz clock as the UART clock then add the following line

    ROM_UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC);

    before UARTStdioConfig for UART-1

    You must use UARTCharPut and UARTCharGet to retrieve data from UART-1

    Regards

    Amit

  • Another poster - clearly comforted/saved - by the ineffectively guard-banded, (yet "Duly Noted") default status of PF0!  

    Or not!   (sadly)