新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > 如何在20分鐘內建立一個NIOS II開發環境

        如何在20分鐘內建立一個NIOS II開發環境

        作者: 時間:2010-06-20 來源:網絡 收藏

        經過以上處理,就可以編譯和下載程序了。
        編譯項目
        從 Processing 菜單選Start compilation,或者Cntl+L,開始編譯。出現警告信息可以不管,等待編譯結束。

        配置 FPGA
        從Tools 菜單選擇Programmer,選擇JTAG 模式和對應的sof 文件,點擊Start,
        開始下載,如果成功,那么開始進入軟件調試

        啟動 IDE
        關閉 Programmer,打開頂層文件。快捷方法就是點圖標

        雙擊 low_cost_1C20 系統模塊,進入SOPC Builder。

        選擇 Run Nios IDE,進入IDE

        軟件工程文件
        選擇 File-》New -》Project 選項。

        選擇 C/C++ Application, 點擊Next。

        從模板中選擇 Hello LED,其他設置按默認設置,點擊Finish。

        編譯工程文件
        選中 hello_led_0,按右鍵,選擇 Build Project

        結束后,右下方的控制臺會提示編譯結束。

        運行程序
        從菜單中選擇 Run-》Run…,彈出對話框

        點擊 New,會自動生成系統配置。

        點擊 Apply,然后點擊Run。
        開始下載程序到 SDRAM,并運行起來。

        觀察板上的 4 個LED,大概沒隔4 秒,LED 會輪流閃爍一次。
        恭喜您,第 C 程序在 CPU 上已經運行起來了。
        如果感興趣,可以修改源文件,然后在編譯,運行,看看 LED 有什么變化
        以下是讓 LED 閃爍更頻繁的例子:
        int main (void) __attribute__ ((weak, alias (alt_main)));
        /*
        * Use alt_main as entry point for this free-standing application
        */
        int alt_main (void)
        {
        alt_u8 led = 0x2;
        alt_u8 dir = 0;
        volatile int i;
        /*
        * Infinitly shift a variable with one bit set back and forth, and write
        * it to the LED PIO. Software loop provides delay element.
        */
        while (1)
        {
        if (led 0x09) // 我們板上只有4個LED,所以當led的Bit3和Bit0有效的時候,
        //就改變方向;
        {
        dir = (dir ^ 0x1);
        }
        if (dir)
        {
        led = led >> 1;
        }
        else
        {
        led = led 1;
        }
        IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led);
        /*
        * The delay element in this design has been written as a while loop
        * to avoid confusing the software debugger. A tight, one line software
        * delay loop such as:
        * for(i=0; i200000; i++);
        * can cause problems when it is stepped through using a software
        debugger.
        * The while loop below produces the same behavior as the for loop shown
        * above, but without causing potential debugger problems.
        */
        i = 0;
        while (i100000) //加快閃爍間隔
        i++;
        }
        return 0;
        }

        本文引用地址:http://www.104case.com/article/151795.htm

        上一頁 1 2 下一頁

        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 鲁山县| 万载县| 博野县| 高安市| 芦溪县| 陆良县| 兴山县| 邯郸市| 禹城市| 收藏| 舞阳县| 遵义县| 六盘水市| 东光县| 综艺| 东丰县| 额济纳旗| 南开区| 陇西县| 盐边县| 茌平县| 大石桥市| 吉安县| 乌鲁木齐县| 和政县| 永城市| 新绛县| 连平县| 鞍山市| 西昌市| 方山县| 修武县| 白银市| 桂平市| 大名县| 灌南县| 通许县| 淳化县| 丰原市| 海盐县| 仙游县|