基于gd32f103vk移植RTTHREAD 3.1.2系统

[复制链接]
932|0
 楼主| zeshoufx 发表于 2019-7-16 11:34 | 显示全部楼层 |阅读模式
一、下载RTT 安装包 下载地址:http://www.keil.com/dd2/pack/
745125d2d43bf676b8.png
二、解压安装到MDK目录下


三、复制RTT到工程里


四、修改board.c
(1)、使用固件库的systick寄存器,,屏蔽rtt的定义
  1. #if 0
  2. #define _SCB_BASE       (0xE000E010UL)
  3. #define _SYSTICK_CTRL   (*(rt_uint32_t *)(_SCB_BASE + 0x0))
  4. #define _SYSTICK_LOAD   (*(rt_uint32_t *)(_SCB_BASE + 0x4))
  5. #define _SYSTICK_VAL    (*(rt_uint32_t *)(_SCB_BASE + 0x8))
  6. #define _SYSTICK_CALIB  (*(rt_uint32_t *)(_SCB_BASE + 0xC))
  7. #define _SYSTICK_PRI    (*(rt_uint8_t  *)(0xE000ED23UL))

  8. // Updates the variable SystemCoreClock and must be called
  9. // whenever the core clock is changed during program execution.
  10. extern void SystemCoreClockUpdate(void);

  11. // Holds the system core clock, which is the system clock
  12. // frequency supplied to the SysTick timer and the processor
  13. // core clock.
  14. extern uint32_t SystemCoreClock;

  15. static uint32_t _SysTick_Config(rt_uint32_t ticks)
  16. {
  17.     if ((ticks - 1) > 0xFFFFFF)
  18.     {
  19.         return 1;
  20.     }
  21.    
  22.     _SYSTICK_LOAD = ticks - 1;
  23.     _SYSTICK_PRI = 0xFF;
  24.     _SYSTICK_VAL  = 0;
  25.     _SYSTICK_CTRL = 0x07;  
  26.    
  27.     return 0;
  28. }
  29. #endif
(2)、修改函数“void rt_hw_board_init()”,
  1. #if 0
  2.         /* System Clock Update */
  3.         SystemCoreClockUpdate();
  4.        
  5.         /* System Tick Configuration */
  6.         _SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  7.         #endif
  8.         SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
(3)、新建“board.h”头文件
  1. #ifndef _board_H
  2. #define _board_H

  3. #include "bitband.h"



  4. void rt_hw_board_init(void);
  5. void SysTick_Handler(void);



  6. #endif

五、修改“rtconfig.h”头文件
  1. //#include "RTE_Components.h"

  2. // <<< Use Configuration Wizard in Context Menu >>>
  3. // <h>Basic Configuration
  4. // <o>Maximal level of thread priority <8-256>
  5. //        <i>Default: 32
  6. #define RT_THREAD_PRIORITY_MAX 32

  7. // <o>OS tick per second
  8. //  <i>Default: 1000   (1ms)
  9. #define RT_TICK_PER_SECOND 1000

  10. // <o>Alignment size for CPU architecture data access
  11. //        <i>Default: 4
  12. #define RT_ALIGN_SIZE 4

  13. // <o>the max length of object name<2-16>
  14. //        <i>Default: 8
  15. #define RT_NAME_MAX 8

  16. // <c1>Using RT-Thread components initialization
  17. //  <i>Using RT-Thread components initialization
  18. #define RT_USING_COMPONENTS_INIT
  19. // </c>

  20. // <c1>Using user main
  21. //  <i>Using user main
  22. #define RT_USING_USER_MAIN
  23. // </c>

  24. // <o>the size of main thread<1-4086>
  25. //        <i>Default: 512
  26. #define RT_MAIN_THREAD_STACK_SIZE 512
六、编译通过
440615d2d458523b1e.png


您需要登录后才可以回帖 登录 | 注册

本版积分规则

67

主题

1991

帖子

15

粉丝
快速回复 在线客服 返回列表 返回顶部