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++);
}
}
