所有RTOS里边我最喜欢RTX,因为点几下就上手了。
1,点MDK的绿色钻石,选择RTX
2,在主函数一定要加上#include "cmsis_os.h"
3,注释掉同RTX冲突定义的三个中断文件
- //void SVC_Handler(void)
- //{
- //
- //}
-
- /****************************************************************************
- ** \brief PendSV_Handler
- **
- ** \param [in] none
- ** \return none
- ** \note
- ****************************************************************************/
- //void PendSV_Handler(void)
- //{
- //
- //}
- /****************************************************************************
- ** \brief SysTick_Handler
- **
- ** \param [in] none
- ** \return none
- ** \note
- ****************************************************************************/
- //void SysTick_Handler(void)
- //{
- //
- //}
-
4,编写函数
- osThreadId tid_ledOn;/* Thread id of thread: ledOn? ? */
-
-
-
- /*----------------------------------------------------------------------------
- ??Thread 1 'ledOn': switches the LED on
- *---------------------------------------------------------------------------*/
- void ledOn (void const *argument) {
- for (;;) {
-
- GPIO0->DO_f.P6 = ~GPIO0->DO_f.P6;
-
- osDelay(200);
- }
- }
-
- int main(void)
- {
- SYS_DisableIOCFGProtect(); /*关闭IOCONFIG写保护*/
- SYS_DisableGPIO0Protect(); /*关闭GPIO0的相关寄存器写保护*/
- SYS_DisableGPIO1Protect(); /*关闭GPIO1的相关寄存器写保护*/
- SYS_DisableGPIO2Protect(); /*关闭GPIO2的相关寄存器写保护*/
- SYS_DisableGPIO3Protect(); /*关闭GPIO3的相关寄存器写保护*/
- SYS_DisableGPIO4Protect(); /*关闭GPIO4的相关寄存器写保护*/
-
- SYS_ConfigHSI(SYS_CLK_HSI_48M); /*设置内部高速时钟为48Mhz*/
- SYS_EnableHSI(); /*开启高速时钟*/
- SYS_ConfigAHBClock(SYS_CLK_SEL_HSI,SYS_CLK_DIV_1); /*设置AHB时钟为高速时钟的1分频*/
- SYS_ConfigAPBClock(AHB_CLK_DIV_1); /*设置APB时钟为AHB时钟的1分频*/
- SystemCoreClockUpdate(); /*刷新SystemCoreCLk、SystemAPBClock变量值*/
-
-
-
- SYS_SET_IOCFG(IOP06CFG,SYS_IOCFG_P06_GPIO);
- GPIO0->DO_f.P6 = 0;
- GPIO_CONFIG_IO_MODE(GPIO0,GPIO_PIN_6,GPIO_MODE_OUTPUT);
-
- //EPWM_Config();
- osThreadDef(ledOn, osPriorityNormal, 1, 0);
- tid_ledOn=osThreadCreate(osThread(ledOn) , NULL);
- osKernelStart();
- while(1)
- {
-
- }
-
-
- }
5,编译一下,成功闪烁