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.

MSP432E401Y: 串口通信怎么得到读取的数据,我使用的是数据回显的例程,例程如下

Part Number: MSP432E401Y


#include <stdint.h>
#include <stdbool.h>
#include "driverlib.h"
#include "uartstdio.h"

#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif


int g_ui32SysClock;
unsigned char a;
void
UART6_IRQHandler(void)
{
  uint32_t ui32Status;

//
// Get the interrrupt status.
//
  ui32Status = MAP_UARTIntStatus(UART6_BASE, true);

//
// Clear the asserted interrupts.
//
  MAP_UARTIntClear(UART6_BASE, ui32Status);

//
// Loop while there are characters in the receive FIFO.
//
  while(MAP_UARTCharsAvail(UART6_BASE))
	{
//
// Read the next character from the UART and write it back to the UART.
//
  MAP_UARTCharPutNonBlocking(UART6_BASE,MAP_UARTCharGetNonBlocking(UART6_BASE));

//
// Blink the LED to show a character transfer is occuring.
//
  GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, GPIO_PIN_0);

//
// Delay for 1 millisecond. Each SysCtlDelay is about 3 clocks.
//
  SysCtlDelay(g_ui32SysClock / (1000 * 3));

//
// Turn off the LED
//
  GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0);
	}
}

void
UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
//
// Loop while there are more characters to send.
//
while(ui32Count--)
{
//
// Write the next character to the UART.
//
MAP_UARTCharPutNonBlocking(UART6_BASE, *pui8Buffer++);
}
}

void InitConsole(void)
{
    /* Enable the clock to GPIO port A and UART 0 */
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    /* Configure the GPIO Port A for UART 0 */
    MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
    MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
    MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    /* Configure the UART for 115200 bps 8-N-1 format with internal 16 MHz
     * oscillator as the UART clock source */
    MAP_UARTClockSourceSet(UART0_BASE, UART_CLOCK_ALTCLK);

    UARTStdioConfig(0, 115200, 16000000);
}

int
main(void)
{
//
// Set the clocking to run directly from the crystal at 120MHz.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
	
	
	InitConsole();
	
//
// Enable the GPIO port that is used for the on-board LED.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);

//
// Enable the GPIO pins for the LED (PN0).
//
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);

//
// Enable the peripherals used by this example.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART6);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);

//
// Enable processor interrupts.
//
MAP_IntMasterEnable();

//
// Set GPIO A0 and A1 as UART pins.
//
GPIOPinConfigure(GPIO_PP0_U6RX);
GPIOPinConfigure(GPIO_PP1_U6TX);
MAP_GPIOPinTypeUART(GPIO_PORTP_BASE, GPIO_PIN_0 | GPIO_PIN_1);

//
// Configure the UART for 115,200, 8-N-1 operation.
//
MAP_UARTConfigSetExpClk(UART6_BASE, g_ui32SysClock, 115200,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));

//
// Enable the UART interrupt.
//
MAP_IntEnable(INT_UART6);
MAP_UARTIntEnable(UART6_BASE, UART_INT_RX | UART_INT_RT);

//
// Prompt for text to be entered.
//


//
// Loop forever echoing data through the UART.
//
while(1)
{
//	a=UARTFR;
	UARTprintf("%d \n",1);
}
}