打算将一个数组的数通过串口发送,处理后返回给pc,在例程基础上修改的,先试验的将接收到的数两两组合存入GetI那个数组中,于是编写的那一段
void UARTIntHandler(void) { unsigned long ulStatus; unsigned char num; int i=1; char Get_tempchar[2]; volatile int temp1; // // Get the interrrupt status. // ulStatus = UARTIntStatus(UART0_BASE, true);
// // Clear the asserted interrupts. // UARTIntClear(UART0_BASE, ulStatus);
// // Loop while there are characters in the receive FIFO. // while(UARTCharsAvail(UART0_BASE)) { for(num=0;num<=1;num++) { Get_tempchar[num]=UARTCharGetNonBlocking(UART0_BASE); } temp1=Get_tempchar[0]<<8; GetI=Get_tempchar[1]+temp1; i=i+1; } }
理想的效果是我发送11 22 33 44 55 66 则GetI[0]=1122 GetI[1]=3344 GetI[2]=5566,但watch这个数组发现总是GetI[1]=5566,其他的都为0,求高手指教,没修改完的源代码如下:
#include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h"
//***************************************************************************** // //! \addtogroup example_list //! <h1>UART Echo (uart_echo)</h1> //! //! This example application utilizes the UART to echo text. The first UART //! (connected to the FTDI virtual serial port on the Stellaris LM3S811 //! Evaluation Board) will be configured in 115,200 baud, 8-n-1 mode. All //! characters received on the UART are transmitted back to the UART. // //*****************************************************************************
//***************************************************************************** // // The error routine that is called if the driver library encounters an error. // //***************************************************************************** #ifdef DEBUG void __error__(char *pcFilename, unsigned long ulLine) { } #endif
int GetI[10]={0}; int GetV[1001]={0};
//***************************************************************************** // // The UART interrupt handler. // //***************************************************************************** void UARTIntHandler(void) { unsigned long ulStatus; unsigned char num; int i=1; char Get_tempchar[2]; volatile int temp1; // // Get the interrrupt status. // ulStatus = UARTIntStatus(UART0_BASE, true);
// // Clear the asserted interrupts. // UARTIntClear(UART0_BASE, ulStatus);
// // Loop while there are characters in the receive FIFO. // while(UARTCharsAvail(UART0_BASE)) { for(num=0;num<=1;num++) { Get_tempchar[num]=UARTCharGetNonBlocking(UART0_BASE); } temp1=Get_tempchar[0]<<8; GetI=Get_tempchar[1]+temp1; i=i+1; } }
//***************************************************************************** // // Send a string to the UART. // //***************************************************************************** void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount) { // // Loop while there are more characters to send. // while(ulCount--) { // // Write the next character to the UART. // UARTCharPutNonBlocking(UART0_BASE, *pucBuffer++); } }
//***************************************************************************** // // This example demonstrates how to send a string of data to the UART. // //***************************************************************************** int main(void) { // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ);
//
// // Enable the peripherals used by this example. // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
// // Enable processor interrupts. // IntMasterEnable();
// // Set GPIO A0 and A1 as UART pins. // GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// // Configure the UART for 115,200, 8-N-1 operation. // UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
UARTFIFOEnable(UART0_BASE); UARTFIFOLevelSet(UART0_BASE, // UART_FIFO_TX4_8, // UART_FIFO_RX1_8); // // // Enable the UART interrupt. // IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
// // Prompt for text to be entered. // UARTSend((unsigned char *)"Enter text: ", 12); //UARTSend(*******,12);
// // Loop forever echoing data through the UART. // while(1) { } }
[ 本帖最后由 fancier 于 2012-4-25 03:25 编辑 ]
|