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.

not sure if im configuring uart correctly



Hey,

So im trying to read data from a magnetic card reader. I have the reader hooked up to a ftdi board from arduino. 

I only have the RX, TX and power pins connected. So i need to have any other pins connected?

im just trying to read the data first to make sure the uart is configured properly. I'm using PC4 and PC5 for RX and TX. I'm just trying to have uart demo echo back the data it receives. 

I have re-configured the uart7 port as so


ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);


ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);


//
// Enable processor interrupts.
//
ROM_IntMasterEnable();

//
// Set GPIO A0 and A1 as UART pins.
//
GPIOPinConfigure(GPIO_PC4_U7RX); //receiving from mag card reader

ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4)//

// Configure the UART for 9600, 
//
ROM_UARTConfigSetExpClk(UART7_BASE, g_ui32SysClock, 9600,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));

//
// Enable the UART interrupt.
//
ROM_IntEnable(INT_UART7);
ROM_UARTIntEnable(UART7_BASE, UART_INT_RX | UART_INT_RT);

The UART0 is also configured for portA  TX as the demo already had for the terminal.

Thank you

  • Ok, I have some edits for the above and its kind of weird. I may not be configuring an rts or cts signal but I was able to find a regular usb cable and test the FTDI board that I have by hooking it up to my computer and using that as a serial port. Now heres the strange thing (and ill show some code) if I configure it that the uart0RX is the computer and the uart7tx data flows through the ftdi board, it works just fine. The moment I reverse the operation (my computer input data flowing through FTDI board and output through mcu) it fails.

    //
    // Enable the peripherals used by this example.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    //uart7 init
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

    //
    // Enable processor interrupts.
    //
    ROM_IntMasterEnable();

    //
    // Set GPIO A0 and A1 as UART pins.
    //
    GPIOPinConfigure(GPIO_PA0_U0RX); //the computer input through the mcu
    GPIOPinConfigure(GPIO_PC5_U7TX); //the output through FTDI board
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0);
    ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_5);
    //this is the one working right now

    //
    // Configure the UART for 115,200, 8-N-1 operation.
    //
    ROM_UARTConfigSetExpClk(UART0_BASE, g_ui32SysClock, 115200,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
    UART_CONFIG_PAR_NONE));
    ROM_UARTConfigSetExpClk(UART7_BASE, g_ui32SysClock, 115200,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
    UART_CONFIG_PAR_NONE));
    //
    // Enable the UART interrupt.
    //
    ROM_IntEnable(INT_UART0);
    ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);

    Now when I try to reverse them, I switch PC5_U7TX to PC4_U7RX and PA0_U0RX to PA1_U0TX and I also the change the bases to the appropriate configurations. This results in the program entering the while(1) loop and getting stuck there. ( also make the changes in the UARTIntHandler();)

    Can anyone shed some light as to what might be happening here? Much appreciated thank you.
  • Hello Daniel

    Why is the UART-7 Transmit pin not being configured?

    Regards
    Amit
  • Hey Amit,

    At first I needed the UART to just read from an external device. I finally got it configured correctly though.
    All I did was disable INT_UART_RT and all was good.
  • Hello Daniel

    It is still not clear as to why INT_UART_RT disabling would cause the issue to go away and what was the issue with it enabled?

    Regards
    Amit
  • when INT_UART_RT was enabled it wouldn't receive characters in the buffer for some reason. I dont remember what post it was but I found one on this forum where someone disabled RT. So I tried it and it worked, I was able to see the data i was sending in.
  • Hello Daniel,

    Receive Timeout interrupt is to read data from the UART RX FIFO when the number of bytes are less than the FIFO RX trigger threshold. So it should have worked.

    Regards
    Amit