Other Parts Discussed in Thread:CC3200
串口接收用中断方式实现,收满一定数目之后通过udp协议无线发走,但是在测试中遇到问题,当串口发送端给3200发送串口数据的时候,每隔10ms发送一包,实际测试速度达到50kb/s(波特率2Mbps),但是查看接收到的数据会有丢包,为了排除是UDP协议的问题,我关闭串口功能,让3200自己产生递增数然后udp发走,实测无丢包,且速度在200kb/s以上,附上串口函数与发送函数,请教各位老师分析一下原因,谢谢!
void uart0_handle() {int lRetVal = MAP_UARTIntStatus(UARTA0_BASE, true);if(lRetVal & UART_INT_RT) //串口空闲中断{while(UARTCharsAvail(UARTA0_BASE)){tempdata1[cnt1++] = MAP_UARTCharGet(UARTA0_BASE);}MAP_UARTIntClear(UARTA0_BASE, UART_INT_RT);}if(lRetVal & UART_INT_RX) //串口接收中断{while(UARTCharsAvail(UARTA0_BASE)){tempdata1[cnt1++] = MAP_UARTCharGet(UARTA0_BASE);}MAP_UARTIntClear(UARTA0_BASE, UART_INT_RX);}MAP_UARTIntClear(UARTA0_BASE,UART_INT_RT|UART_INT_RX); //清中断 }
while(1){ if(cnt1 == PACKAGE){ for(t=0;t<cnt1;t++)MAP_UARTCharPut(UARTA0_BASE,tempdata1[t]); // iStatus1 = sl_SendTo(iSockID, tempdata1, PACKAGE, 0,(SlSockAddr_t *)&sAddr, iAddrSize); cnt1 = 0;} }
Terry Han:
建议先排除UART串口传输数据到CC3200 M4处理器部分的程序,如果大数据量的串口传输数据,建议打开DMA并且增加使能UART的FIFO功能,减小中断的次数,提高传输的效率,或者直接使用SPI的方式传输大数据给CC3200的M4内核,
其中关于
SPI DMA的例子:
https://github.com/severin-kacianka/cc3200_dma_spi_example/ cc3200_dma_spi_example
Here are two examples that show how to use SPI with DMA and FIFO on the CC3200. I hope that they are a useful starting point for anyone, who wants to work on SPI and DMA in the future.
The examples are compiling fine on Linux with gcc 4.9.3 from http://launchpad.net/gcc-arm-embedded. All you need to change is the path for the SDK in the Makefile. The hardware setup is similar to the SPI example in the SDK: just connect two CC3200 via cable (Pins GND, P05, P06, P07 and P08). I have set the following jumpers: J6, J7, J8. J9. J10, J11, J12, J13.
simple_spi_transfer is an example of an SPI transfer without DMA and FIFO. The master sends a buffer to the slave, reads it back in the next transfers and verifies the checksums.
transfer_1024_byte implements a simple SPI/DMA transfer that will transfer 1024 (or whatever DMA_SIZE is set to) bytes from the master to the slave and back. It then calculates the buffer's CRC checksum and (on the master) compares the send checksum to the received checksum.
transfer_64k shows how to transfer a 64k buffer from the master to the slave and back again.
windows contains a Makefile send to me by Matt van de Werken that also works using the Launchpad tools in a Cygwin enviroment
,
zhuming su:
请问,CC3200串口支持哪些波特率?
,
Terry Han:
你好,最大到3Mbps
The CC3200 device includes two UARTs with the following features:• Programmable baud-rate generator allowing speeds up to 3 Mbps• Separate 16 x 8 TX and RX FIFOs to reduce CPU interrupt service loading• Programmable FIFO length, including 1-byte deep operation providing conventional double-buffered interface• FIFO trigger levels of 1/8, 1/4, 1/2, 3/4, and 7/8• Standard asynchronous communication bits for start, stop, and parity• Line-break generation and detection• Fully programmable serial interface characteristics– 5, 6, 7, or 8 data bits– Even, odd, stick, or no-parity bit generation and detection– 1 or 2 stop-bit generation• RTS and CTS hardware flow support• Standard FIFO-level and End-of-Transmission interrupts• Efficient transfers using μDMA– Separate channels for transmit and receive– Receive single request asserted when data is in the FIFO; burst request asserted at programmed FIFOlevel– Transmit single request asserted when there is space in the FIFO; burst request asserted at programmedFIFO level• System clock is used to generate the baud clock
,
Chen ZhengLong:
你好!请教一下,。我的串口代码无法进入到中断程序,是什么原因?是否可以分析一下?谢谢!!!
static void UART_HANDLE(void){ int i_inter,numOfChar; char cTemp; i_inter = UARTIntStatus(UARTA0_BASE, true); numOfChar = 0; if(i_inter & UART_INT_RX) { while(UARTCharsAvail(UARTA0_BASE)) { cTemp = UARTCharGet(UARTA0_BASE); g_cBsdBuf[numOfChar] = cTemp; numOfChar++; UARTCharPut(UARTA0_BASE, 'B'); UARTCharPut(UARTA0_BASE, cTemp); } } g_cBsdBuf[numOfChar+1] = '\0';
UARTIntClear(UARTA0_BASE, UART_INT_RX);}
void UART0_INIT(void){ PRCMPeripheralClkEnable(PRCM_UARTA0,PRCM_RUN_MODE_CLK);
PinTypeUART(PIN_55, PIN_MODE_3); PinTypeUART(PIN_57, PIN_MODE_3);
UARTConfigSetExpClk(UARTA0_BASE,PRCMPeripheralClockGet(PRCM_UARTA0),\ UART_BAUD_RATE,(UART_CONFIG_WLEN_8|UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE));
UARTIntRegister(UARTA0_BASE,UART_HANDLE);
UARTIntEnable(UARTA0_BASE,UART_INT_RX);
UARTFIFODisable(UARTA0_BASE);
UARTFIFOLevelSet(UARTA0_BASE,UART_FIFO_TX1_8,UART_FIFO_RX1_8);}
主函数内的内容如下:
UART0_INIT();//// UART_PRINT("Connected to AP: %s \n\r",SSID_NAME);// BsdTcpClient(g_uiPortNum); g_cBsdBuf[0] = 'A'; int ii = 0; for(;ii < 3; ii++) {// Message("VRPT"); UARTCharPut(UARTA0_BASE, 'a'); UtilsDelay(8000000);// Report("\n\rcmd#%s\n\r", g_cBsdBuf);
g_cBsdBuf[ii+1] = 'c'; g_cBsdBuf[ii+2] = '\0'; } BsdTcpClient(g_uiPortNum);