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 rts

Other Parts Discussed in Thread: EK-TM4C123GXL

Hello,

I am using EK-TM4C123GXL. I am trying to have a communication between  UART1 and an rf module. My rf module signals that UART communication is possible by sending low; and high when the buffer is full (128 byte) with the RTS output . Therefore, I assigned one of my GPIO (here PF4) as an input which is connected to the RTS pin of the rf module. I am using

 if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0) command before sending data to the rf module.  I sent 128 character to make  RTS high and  write the following command:

if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0x10) 

{ rtswillhigh=1;}

(int rtswillhigh=0 initially)

       But rtswillhigh remains zero, I am wondering whether code is true or not. In addition, I disable the cts pin of the rf module and connect it to the one of my GPIO as well. (since it says the module will check this pin before a new byte is transmitted via UART) I think it is not necessary to use. Am I wrong? I will appreciate any suggestions. 

Thanks in advance.

  • Hello Bilge

    The code looks fine. If you can share the configuration of the pin as GPIO it would be of much use.

    Also it is not clear as to the code expects to poll this bit in a loop somewhere, because if the event occurs momentarily and then goes back it could be possible to miss the if statement.

    Regards

    Amit

  • Hello Amit

    Thanks for your reply. My code for configuration and loop is as follows:

    #include "stdint.h"
    #include "stdbool.h"
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"

    int rtswillhigh=0;

    int main(void) {

    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |SYSCTL_OSC_MAIN );

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);


    GPIOPinConfigure(GPIO_PB0_U1RX);

    GPIOPinConfigure(GPIO_PB1_U1TX);

    GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    /*RTS*/
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_4);

    /*CTS  I will not use just wire to the tivac*/
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_2);

    UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 9600,
    (UART_CONFIG_WLEN_7 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_EVEN));

    /*My for loop */

    int y=0;

    for(y=0;y<200;y++)
     {
            if(GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0)
            {
                 UARTCharPut(UART1_BASE,'A');

            }
           else if (GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4)==0x10)
            {
                 y--;
                rtswillhigh=1;
             }
    }

    }

    I force to send 200 characters so that rtswillhigh should be 1. But unfortunately it is not. I could not find where I am wrong.

    Thanks in advance.

  • Hello Bilge,

    The code looks fine. Have you checked on a scope that on transmission of >128 bytes the RTS from the RF chip to TIVA becomes high?

    Regards

    Amit

  • Hello Amit,

    Actually I have no oscillator but the voltage of RTS pin (output of Rf chip) is zero all the time. At least, I know the problem is not with the code. I am so grateful for all your help.

    Thanks

    Bilge