请选择 进入手机版 | 继续访问电脑版
查看: 1477|回复: 0

EK-LM3S8962 以太网速度测试 96Mbps ! (无OS、无协议栈)

[复制链接]
发表于 2016-4-7 21:36:12 | 显示全部楼层 |阅读模式
本来另外一个帖子里已经讲过了,不过还是按捺不住激动要郑重的通知大家一下 ^_^

用免费申请的EK-LM3S8962开发板,写了一个简单的以太网发送速度测试程序,发送的数据是一个固定的UDP报文,循环反复发送,实测PC端网卡占用率 96%,也就是在 96Mbps 左右!

当然这个测试不涉及任何计算,实际应用中是没有意义的,不过可以看出LM的网口效率还是挺高的,如果能用DMA的话就更好了。(8962好像没有DMA?9000系列才有?)

另外,说明一下,这个测试是没有跑协议栈的,更没有操作系统,只是单纯的往网口的FIFO写数据,测试以太网帧的发送速度。目的是为了了解一下器件传输速度的极限,无实际应用意义。



PC端网络占用率 (原文件名:netload.JPG)


Wireshark抓包结果 (原文件名:pak.JPG)
测试代码:略去UDP报文数据部分(太长)

#include "../../../inc/hw_ints.h"
#include "../../../inc/hw_memmap.h"
#include "../../../inc/hw_nvic.h"
#include "../../../inc/hw_types.h"
#include "../../../inc/hw_ethernet.h"
#include "../../../driverlib/sysctl.h"
#include "../../../driverlib/gpio.h"
#include "../../../driverlib/ethernet.h"


static unsigned char nMACAddr[] = {0x00, 0x07, 0x63, 0x04, 0xF9, 0x30, 0x00, 0x00};
static unsigned char nSendData[] = {
/*Length = 1066 - 14 = 1052(0x041c)*/
                        0x1c, 0x04,                        
/*Frame*/
/*0000*/        0x00, 0x14, 0x2a, 0x6c, 0xae, 0xa8, 0x00, 0x07, 0x63, 0x04, 0xf9, 0x30, 0x08, 0x00, 0x45, 0x00,

// 此处略去若干行
// ......
//

/*Pads*/
                        0x00, 0x00//, 0x00, 0x00
};

int main(void)
{
        unsigned long* pS;
        unsigned long nEthClk, ulTemp;
        int i;

        // Set the clocking to run at 50MHz from the PLL.
        SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);

        // Enable and Reset the Ethernet Controller.
        SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH);
        SysCtlPeripheralReset(SYSCTL_PERIPH_ETH);
        
        // Enable Port F for Ethernet LEDs.
        //  LED0        Bit 3   Output
        //  LED1        Bit 2   Output
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
        GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3, GPIO_DIR_MODE_HW);
        GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        
        // Intialize the Ethernet Controller and disable all Ethernet Controller
        // interrupt sources.
        EthernetIntDisable(ETH_BASE, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER | ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX));
        ulTemp = EthernetIntStatus(ETH_BASE, false);
        EthernetIntClear(ETH_BASE, ulTemp);
        
        // Initialize the Ethernet controller for operation
        nEthClk = SysCtlClockGet();
        EthernetInitExpClk(ETH_BASE, nEthClk);

        // Configure the Ethernet controller for normal operation
        // Enable TX Duplex Mode
        // Enable TX Padding
        EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN | ETH_CFG_TX_PADEN | ETH_CFG_TX_CRCEN));

        HWREG(ETH_BASE + MAC_O_THR) = 0x0;

        // Program the MAC Address (01-23-45-67-89-AB)
        EthernetMACAddrSet(ETH_BASE, nMACAddr);

        // Enable the Ethernet controller
        EthernetEnable(ETH_BASE);

        // Send
        while(1)
        {
                // Wait for current packet (if any) to complete.
                while(HWREG(ETH_BASE + MAC_O_TR) & MAC_TR_NEWTX)
                {
                }

                // Copy data to FIFO
                pS = (unsigned long*)nSendData;
                for ( i = 0; i < sizeof(nSendData) / 4; i++ )
                        HWREG(ETH_BASE + MAC_O_DATA) = *pS++;

                // Activate the transmitter
                // HWREG(ETH_BASE + MAC_O_TR) = MAC_TR_NEWTX;
        }
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入因仑

本版积分规则

快速回复 返回顶部 返回列表