一、下载RTT 安装包 下载地址:http://www.keil.com/dd2/pack/
二、解压安装到MDK目录下
三、复制RTT到工程里
四、修改board.c
(1)、使用固件库的systick寄存器,,屏蔽rtt的定义
- #if 0
- #define _SCB_BASE (0xE000E010UL)
- #define _SYSTICK_CTRL (*(rt_uint32_t *)(_SCB_BASE + 0x0))
- #define _SYSTICK_LOAD (*(rt_uint32_t *)(_SCB_BASE + 0x4))
- #define _SYSTICK_VAL (*(rt_uint32_t *)(_SCB_BASE + 0x8))
- #define _SYSTICK_CALIB (*(rt_uint32_t *)(_SCB_BASE + 0xC))
- #define _SYSTICK_PRI (*(rt_uint8_t *)(0xE000ED23UL))
- // Updates the variable SystemCoreClock and must be called
- // whenever the core clock is changed during program execution.
- extern void SystemCoreClockUpdate(void);
- // Holds the system core clock, which is the system clock
- // frequency supplied to the SysTick timer and the processor
- // core clock.
- extern uint32_t SystemCoreClock;
- static uint32_t _SysTick_Config(rt_uint32_t ticks)
- {
- if ((ticks - 1) > 0xFFFFFF)
- {
- return 1;
- }
-
- _SYSTICK_LOAD = ticks - 1;
- _SYSTICK_PRI = 0xFF;
- _SYSTICK_VAL = 0;
- _SYSTICK_CTRL = 0x07;
-
- return 0;
- }
- #endif
(2)、修改函数“void rt_hw_board_init()”,
- #if 0
- /* System Clock Update */
- SystemCoreClockUpdate();
-
- /* System Tick Configuration */
- _SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
- #endif
- SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
(3)、新建“board.h”头文件
- #ifndef _board_H
- #define _board_H
- #include "bitband.h"
- void rt_hw_board_init(void);
- void SysTick_Handler(void);
- #endif
五、修改“rtconfig.h”头文件
- //#include "RTE_Components.h"
- // <<< Use Configuration Wizard in Context Menu >>>
- // <h>Basic Configuration
- // <o>Maximal level of thread priority <8-256>
- // <i>Default: 32
- #define RT_THREAD_PRIORITY_MAX 32
- // <o>OS tick per second
- // <i>Default: 1000 (1ms)
- #define RT_TICK_PER_SECOND 1000
- // <o>Alignment size for CPU architecture data access
- // <i>Default: 4
- #define RT_ALIGN_SIZE 4
- // <o>the max length of object name<2-16>
- // <i>Default: 8
- #define RT_NAME_MAX 8
- // <c1>Using RT-Thread components initialization
- // <i>Using RT-Thread components initialization
- #define RT_USING_COMPONENTS_INIT
- // </c>
- // <c1>Using user main
- // <i>Using user main
- #define RT_USING_USER_MAIN
- // </c>
- // <o>the size of main thread<1-4086>
- // <i>Default: 512
- #define RT_MAIN_THREAD_STACK_SIZE 512
六、编译通过
|