0
\$\begingroup\$

In the aforementioned board, port C is 8 pins in which 0-3 are used for JTAG (So 4-7 should be GPIO available right?). I am using the following code:

#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c1294ncpdt.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_memmap.h"

int main(void)
{
    SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 12000000);

    SYSCTL_RCGCUART_R = SYSCTL_RCGCUART_R3;
    while((SYSCTL_PRUART_R & SYSCTL_PRUART_R3) == 0);

    SYSCTL_RCGCGPIO_R = SYSCTL_RCGCGPIO_R0;
    while((SYSCTL_PRGPIO_R & SYSCTL_PRGPIO_R0) == 0);

    // HWREG(GPIO_PORTC_BASE+ GPIO_O_LOCK) = GPIO_LOCK_KEY;
    // HWREG(GPIO_PORTC_BASE + GPIO_O_CR) |= (GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);

    GPIO_PORTA_AHB_AFSEL_R = GPIO_PIN_4 | GPIO_PIN_5;
    GPIO_PORTA_AHB_PCTL_R  = 0x00110000;
    GPIO_PORTA_AHB_DEN_R   = GPIO_PIN_4 | GPIO_PIN_5;

    // UART3_LCRH_R &= ~UART_LCRH_FEN;
    UART3_IBRD_R  = 78;
    UART3_FBRD_R  = 8;
    UART3_LCRH_R |= UART_LCRH_WLEN_8;
    UART3_CC_R    = 0x0;
    // UART3_LCRH_R |= UART_LCRH_FEN;
    // UART3_CTL_R  |= UART_CTL_TXE | UART_CTL_UARTEN;
    UART3_CTL_R  |= UART_CTL_UARTEN;

    while(1)
    {
        while( (UART3_FR_R & 0x0020) != 0);
        UART3_DR_R = (char) 'a';
        SysCtlDelay(1000000);
    }
}

The code is configured to work with UART 3 (RCGCUART_R3) module which resides on port A (RCGCGPIO_R0) pins 4 & 5. Changing the configuration to UART 5 which resides on port C pins 6 & 7 will successfully download the binary to the board on the first time only, on the subsequent trials I always get "Unable to initialize target - 0". I still get the error after the first successful programming even after doing the Unlock Sequence

Trying to unlock port C even with port A is used in UART does not work. The previous code won't print the character 'a' when the unlock sequence is uncommented. Does the board see port C as one unit so I have to unlock the whole register? The schematic confirms that pins 0-3 are for JTAG while the rest are for GPIO.

Another question is the use of UART FIFO buffers. Correct if i'm wrong, the FIFO is a buffer used to receive/write data between the serial port and the memory. But what i'm not sure of it, when do I really need it and when I do not need it?

Another question, in general is it possible to detect that the UART port is connected? For example, detect an FTDI FT232 chip when it is connected to the appropriate pins.

Thank u very much!

\$\endgroup\$
  • \$\begingroup\$ Are you using the TI Eval Kit EK-TM4C1294XL, or did you create your own board? \$\endgroup\$ – Tyler Mar 5 '18 at 14:44
  • \$\begingroup\$ Yes the EK-TM4C1294XL. \$\endgroup\$ – 3bdalla Mar 5 '18 at 14:45
  • \$\begingroup\$ No, it has 8 UARTs. See page 1161 \$\endgroup\$ – 3bdalla Mar 5 '18 at 18:35
  • \$\begingroup\$ Have you looked at the example uart_echo? You seem to be missing some enables. \$\endgroup\$ – Tyler Mar 5 '18 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.