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.

TM4C129XNCZAD: SIR Rx Pin does not work

Part Number: TM4C129XNCZAD

Hi,

I am trying to use the SIR feature of the UART to transmit 8 bits data out from PC5 and receive back the same data through PC4. The pin PC5 is connected with an IR emitter and the pin PC4 is connected with a phototransistor. I have managed to transmit and received the data wirelessly using the IR. However, the received data is not able to be captured in the UART receive buffer. Attached is the IR signals I captured at both PC4 and PC5 to proof that the signal is successfully transmitted. I have also attached my code for reference. Hope to hear some advice from the expert in this forum. Thanks.

#include <stdbool.h>
#include <stdint.h>
#include "sysctl.h"
#include "clock.h"
#include "gpio.h"
#include "uart.h"

char rxData = 0x00;
int j;

void uartHandler()
{

UARTIntClear(UART7_BASE, UART_INT_RX);

//if(UARTIntStatus(UART7_BASE, true) & UART_INT_RX)
//{
rxData = UARTCharGetNonBlocking(UART7_BASE);
for(j=0; j<7000000; j++);

//}
}


int main(void)
{
    int i;
    int32_t ui32SysClock;

    ui32SysClock = ClockFrequencySet(120000000);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_UART7));
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOC));

    GPIOPinConfigure(GPIO_PC5_U7TX);
    GPIOPinConfigure(GPIO_PC4_U7RX);
    GPIOPinTypeUART(GPIO_PORTC_AHB_BASE, GPIO_PIN_5); //Tx
    GPIOPinTypeUART(GPIO_PORTC_AHB_BASE, GPIO_PIN_4); //Rx

    UARTEnableSIR(UART7_BASE, 0);
    //UARTDisableSIR(UART7_BASE);
    UARTConfigSetExpClk(UART7_BASE, ui32SysClock, 2400, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    UARTFIFODisable(UART7_BASE);
    UARTIntRegister(UART7_BASE, uartHandler);
    UARTIntEnable(UART7_BASE, UART_INT_RX);

    while(1)
    {
        UARTCharPut(UART7_BASE, 0x21);
        while(UARTBusy(UART7_BASE));
        for(i=0; i<7000000; i++);
        rxData = UARTCharGetNonBlocking(UART7_BASE);
        for(j=0; j<7000000; j++);
    }
}

  • Hi all,

    I managed to get it work after reading the datasheet again.I was triggered by the word half-duplex and decided to use another UART eg UART5 Rx pin to receive the transmitted data. And i successfully received it!. Not sure if this is the work around. Would still appreciate the reply if there are other solution to this problem. Thanks!

  • Hi,

      Your understanding is correct that half-duplex means you cannot transmit and receive at the same time. You would need to use two UARTs to transmit and receive at the same time. 

      See below datasheet excerpt. 

    19.3.4 Serial IR (SIR)
    The UART peripheral includes an IrDA serial-IR (SIR) encoder/decoder block. The IrDA SIR block
    provides functionality that converts between an asynchronous UART data stream and a half-duplex
    serial SIR interface. No analog processing is performed on-chip. The role of the SIR block is to
    provide a digital encoded output and decoded input to the UART. When enabled, the SIR block
    uses the UnTx and UnRx pins for the SIR protocol. These signals should be connected to an infrared
    transceiver to implement an IrDA SIR physical layer link. The SIR block can receive and transmit,
    but it is only half-duplex so it cannot do both at the same time.