I am having problem receiving characters on the UART port 2 Rx pin. I have connected (hardware) pins PB1 (Tx ox UART1) to PD6 (Rx of UART2). I am transmitting data from the UART1 port succesfully, but unable to receive anything on the UART port 2 Rx pin. I am posting the code too. Even a small help would be appreciated in this direction.
#include <stdbool.h> #include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h" #include "utils/uartstdio.h" #include "driverlib/interrupt.h" #include "inc/hw_ints.h" #include "driverlib/rom_map.h" #include "utils/uartstdio.h" //***************************************************************************** //***************************************************************************** // // This function sets up UART1 to be used for communication between launchpad // and GPS Module. // //***************************************************************************** void ConfigureUART1(void) { // // Enable GPIO port B which is used for UART1 pins. // TODO: change this to whichever GPIO port you are using. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // // Configure the pin muxing for UART1 functions on port B0 and B1. // This step is not necessary if your part does not support pin muxing. // TODO: change this to select the port/pin you are using. // GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); // // Enable UART1 so that we can configure the clock. // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); // // Use the internal 16MHz oscillator as the UART clock source. // Check with sir // UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC); // // Select the alternate (UART) function for these pins. // TODO: change this to select the port/pin you are using. // GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Initialize the UART1. // //UARTStdioConfig(1, 9600, 16000000); UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC); UARTConfigSetExpClk(UART1_BASE, UART_CLOCK_PIOSC ,9600,UART_CONFIG_PAR_ZERO); UARTFIFOEnable(UART1_BASE); } //***************************************************************************** // // This function sets up UART2 to be used for communication between UART1 and UART2. // //***************************************************************************** void ConfigureUART2(void) { // // Enable GPIO port D which is used for UART2 pins. // TODO: change this to whichever GPIO port you are using. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // // Configure the pin muxing for UART2 functions on port D6 and D7. // This step is not necessary if your part does not support pin muxing. // TODO: change this to select the port/pin you are using. // GPIOPinConfigure(GPIO_PD6_U2RX); GPIOPinConfigure(GPIO_PD7_U2TX); // // Enable UART1 so that we can configure the clock. // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2); // // Use the internal 16MHz oscillator as the UART clock source. // Check with sir // UARTClockSourceSet(UART2_BASE, UART_CLOCK_PIOSC); // // Select the alternate (UART) function for these pins. // TODO: change this to select the port/pin you are using. // GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7); // // Initialize the UART1. // //UARTStdioConfig(1, 9600, 16000000); UARTClockSourceSet(UART2_BASE, UART_CLOCK_PIOSC); UARTConfigSetExpClk(UART2_BASE, UART_CLOCK_PIOSC ,9600,UART_CONFIG_PAR_ZERO); UARTFIFOEnable(UART2_BASE); } //***************************************************************************** // // This function provides a 1 second delay using a simple polling method. // //***************************************************************************** void SimpleDelay(void) { // // Delay cycles for 1 second // SysCtlDelay(16000000 / 3); } //***************************************************************************** // // Send a string to the UART0. // //***************************************************************************** void UART1Send(const uint8_t *pui8Buffer, uint32_t ui32Count) { // // Loop while there are more characters to send. // while(ui32Count--) { // // Write the next character to the UART. // while(!UARTSpaceAvail(UART1_BASE)){ //Wait till space in Tx FIFO is available. UARTFIFODisable(UART1_BASE); UARTFIFOEnable(UART1_BASE); } UARTCharPut(UART1_BASE, *pui8Buffer++); // // Turn on the LED (Green). // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_PIN_3); SimpleDelay(); // Turn off the LED (Green). // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0x00); // // Turn on the LED (Blue). // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); SimpleDelay(); // // Turn off the LED (Blue). // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0x00); } } //***************************************************************************** // // Configuration for blinking LEDs. // //***************************************************************************** void ConfigureLED(void){ // // Enable the GPIO port that is used for the on-board LED. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // // Check if the peripheral access is enabled. // while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF)) { } // // Enable the GPIO pin for the LED (PF3, PF2, PF1). // Set the direction as output, and enable the GPIO // pin for digital function. // GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); } //***************************************************************************** // // Main Function // //***************************************************************************** int main(void) { ConfigureLED(); ConfigureUART1(); ConfigureUART2(); while(true){ uint32_t rec = 0; UART1Send((uint8_t *)"ABCDEFGHIJKLMNOP",16); SimpleDelay(); while(!UARTCharsAvail(UART2_BASE)){ // // Wait till a character is present in the Receive FIFO of UART2. // } // // Fetch the character. 'rec' will be true or false depending on the // presence of character in the receive FIFO. // rec = UARTCharGetNonBlocking(UART2_BASE); if(rec){ // // Turn on the RED LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_PIN_1); SimpleDelay(); // // Turn off the RED LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0x00); SimpleDelay(); } } }