Hi
I have configured uart1 using the uart echo example code as given below. But I am getting data at terminal different from the data what I am sending. Could any one suggest me to solve this problem.
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"
#include "grlib/grlib.h"
#include "drivers/cfal96x64x16.h"
#include "utils/uartstdio.h"
#include "driverlib/rom_map.h"
//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif
//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend( unsigned char *pucBuffer, unsigned long ulCount)
{
//
// Loop while there are more characters to send.
//
while(ulCount--)
{
//
// Write the next character to the UART.
//
ROM_UARTCharPutNonBlocking(UART1_BASE, *pucBuffer++);
}
}
//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
unsigned char buf[256] = {0};
unsigned char * pucBuffer = buf;
void
UARTIntHandler(void)
{
unsigned long ulStatus;
//UARTprintf("Inside Interrupt Handler\n");
//
// Get the interrrupt status.
//
ulStatus = ROM_UARTIntStatus(UART1_BASE, true);
//
// Clear the asserted interrupts.
//
ROM_UARTIntClear(UART1_BASE, ulStatus);
#if 0
//
// Loop while there are characters in the receive FIFO.
//
while(UARTCharsAvail(UART1_BASE))
{
//
// Read the next character from the UART and write it back to the UART.
//
//UARTCharGet(UART0_BASE);
//UARTCharPut( UART0_BASE,UARTCharGet(UART0_BASE));
//ROM_UARTCharPutNonBlocking(UART0_BASE,
//ROM_UARTCharGetNonBlocking(UART0_BASE);
*pucBuffer++= UARTCharGetNonBlocking(UART0_BASE);
// UARTCharPut( UART0_BASE,UARTCharGet(UART0_BASE));
}
UARTSend(&buf[0],strlen(buf));
pucBuffer = buf;
memset(buf,0x00,sizeof(buf));
#endif
}
//*****************************************************************************
//
// This example demonstrates how to send a string of data to the UART.
//
//*****************************************************************************
int
main(void)
{
ROM_FPUEnable();
ROM_FPULazyStackingEnable();
//
// Set the clocking to run directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
ROM_GPIOPadConfigSet(GPIO_PORTC_BASE,GPIO_PIN_4 | GPIO_PIN_5,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_OD);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4);
ROM_GPIOPinConfigure(GPIO_PC4_U1RX);
ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_5);
ROM_GPIOPinConfigure(GPIO_PC5_U1TX);
ROM_UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(),115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//
// Enable processor interrupts.
//
ROM_IntMasterEnable();
#if 1
//
// Enable the UART interrupt.
//
ROM_IntEnable(INT_UART1);
#endif
ROM_UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);
//
// Loop forever echoing data through the UART.
while(1){
UARTCharPut(UART1_BASE,'A');
}
Thank you.
Regards,
Anand