找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

帖子
查看: 7308|回復(fù): 3
打印 上一主題 下一主題
收起左側(cè)

Proteus8.9 GCC編譯器仿真RtThread RealTime STM32F401VE_系列002_動(dòng)態(tài)線程跑馬燈

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
本帖最后由 kaillen 于 2020-8-7 23:32 編輯

一,打開文件(可以隨文下載放置在文檔中打開)。(如下圖1所示)

圖1

二,調(diào)整原理圖大小,適合可視,另存工程文件。(如下圖2,3,4所示)


圖2



圖3



圖4

三,點(diǎn)擊Source Code標(biāo)簽。(如下圖5所示)


圖5

四,編輯main.c Proteus8.9 VSM Studio GCC編譯器仿真RtThread RealTime STM32F103R6_系列002_動(dòng)態(tài)線程跑馬燈 (如下圖6所示)

五,Main.c 代碼:


/* Main.c file generated by New Project wizard
* Author:   Ziegler Yin
* Created:   周四 一月 16 2020
* Processor: STM32F407ZGT6ZGT6
* Compiler:  GCC for ARM
*/

#include "mfuncs.h"
#include "delay.h"
#include "usart.h"
#include "sys.h"

#include <rtthread.h>

#define LED0 PCout(0)
#define LED1 PCout(1)
#define LED2 PCout(2)



#ifndef RT_USING_HEAP
        static struct rt_thread led_thread;
        static char led_thread_stack[256];
#else
        static rt_thread_t led_thread;
#endif

        
static void MX_GPIO_Init(void)
{
          GPIO_InitTypeDef  GPIO_InitStructure;
          RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);//使能GPIOF時(shí)鐘
          //GPIOF9,F10初始化設(shè)置
          GPIO_InitStructure.GPIO_Pin= GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;//LED對(duì)應(yīng)引腳
          GPIO_InitStructure.GPIO_Mode= GPIO_Mode_OUT;//普通輸出模式
          GPIO_InitStructure.GPIO_OType= GPIO_OType_PP;//推挽輸出
          GPIO_InitStructure.GPIO_Speed= GPIO_Speed_100MHz;//100MHz
          GPIO_InitStructure.GPIO_PuPd= GPIO_PuPd_UP;//上拉
          GPIO_Init(GPIOC, &GPIO_InitStructure);//初始化

                LED0= 0;
                LED1= 1;
}


static void led_thread_entry(void * parameter) {
        while(1) {
                LED0= ~LED0;
                LED1= ~LED1;               
                uprint("控制芯片STM32F401VE_RtThread RealTime_跑馬燈仿真開始了。\r\n");
                rt_thread_mdelay(500);
        }
}


int main(void)
{
        delay_init(84);  //初始化延時(shí)函數(shù)
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設(shè)置系統(tǒng)中斷優(yōu)先級(jí)分組2
        uart_init(9600);//初始化串口波特率為115200
    MX_GPIO_Init();
        
        #ifndef RT_USING_HEAP
                        rt_err_t rst;
                        rst= rt_thread_init(&led_thread,
                                                                                                "ledshine",
                                                                                                led_thread_entry,
                                                                                                RT_NULL,
                                                                                                &led_thread_stack[0],
                                                                                                sizeof(led_thread_stack),
                                                                                                RT_THREAD_PRIORITY_MAX - 2,
                                                                                                20);
                        if(rst== RT_EOK) {
                                rt_thread_startup(&led_thread);
                        }
                #else
                        led_thread= rt_thread_create("ledshine",
                                                                                                                                                led_thread_entry,
                                                                                                                                                RT_NULL,
                                                                                                                                                256,
                                                                                                                                                RT_THREAD_PRIORITY_MAX - 2,
                                                                                                                                                20);
                        if(led_thread!= RT_NULL) {
                                rt_thread_startup(led_thread);
                        }
                #endif
                 while(1) {
                         rt_thread_mdelay(100);
                }
}





六,點(diǎn)擊構(gòu)建工程按鈕,編譯工程。(如下圖6所示)


圖6

七,點(diǎn)擊窗口左下方仿真按鈕,可見虛擬LED顯示。 (如下圖7,8,9所示)


圖7

圖8


圖9


八,選擇release,點(diǎn)擊構(gòu)建工程按鈕,編譯工程生成Hex文件。(如下圖10所示)



圖10


附件Proteus8.9 VSM Studio GCC編譯器仿真RtThread RealTime STM32F401VE_系列002_動(dòng)態(tài)線程跑馬燈在已安裝Proteus8.9的計(jì)算機(jī)文件夾中打開即可
需要進(jìn)一步了解,請(qǐng)加入QQ群:976235464


RtThread_GCC_F401VE_002_動(dòng)態(tài)線程_跑馬燈02pt.rar

425 KB, 下載次數(shù): 40, 下載積分: 黑幣 -5

在已安裝Proteus8.9的計(jì)算機(jī)文件夾中打開即可

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:64019 發(fā)表于 2022-5-4 08:52 | 只看該作者
仿真提示錯(cuò)誤
回復(fù)

使用道具 舉報(bào)

板凳
ID:228452 發(fā)表于 2022-5-8 16:33 | 只看該作者
No source code , no .elf ,no .hex  only Proteus ?
回復(fù)

使用道具 舉報(bào)

地板
ID:228452 發(fā)表于 2022-5-8 17:31 | 只看該作者
oops

click the Source Code tab. As shown in Figure 5

Thank you for the project



回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表