第一次用Keil的RTOS,怎么也玩不转,两个跑马灯都没亮,请高手指点:
我用的官方的LM3S8962开发板,MDK环境。8MHz。
我的代码如下:,不知道为什么,用软件simulate都不行, 执行到main的 os_sys_init (task1)后就不行了,进入不了任何task的断点;
编译没有问题,Option选项选择了RTX 内核了。不知道是哪设置的问题?代码是改自官方timer interval例子,别人用的LPC2300,我用8962试试,玩不转!!!求救
#include <LM3Sxxx.H>
#define LED_BASE GPIO_PORTF_BASE
#define LED GPIO_PIN_0
#include <RTL.h> /* RTX kernel functions & defines */
/* id1, id2 will contain task identifications at run-time */
void task1 (void) ; // Tsk function prototypes
void task2 (void) ;
void task3 (void) ;
OS_TID tsk1,tsk2,tsk3; // Define the task ID variables
/*----------------------------------------------------------------------------
* Task 1: RTX Kernel starts this task with os_sys_init (task1)
*---------------------------------------------------------------------------*/
void LED_Init(void)
{
/* Obtain own system task identification number */
SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_OSC_MAIN|
SYSCTL_XTAL_8MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPadConfigSet(LED_BASE,LED,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
GPIOPinTypeGPIOOutput(LED_BASE,LED);
GPIOPinWrite(LED_BASE, LED, 1);
}
/*----------------------------------------------------------------------------
* Main: Initialize and start RTX Kernel
*---------------------------------------------------------------------------*/
__task void task1 (void) //Define the function as an RTX task
{
os_itv_set (25); //set an interval of 250 Msec
tsk2 = os_tsk_create(task2,0x10); //Create the second task and assign its priority
os_itv_wait (); //halt the task for 250 Msec
tsk3 = os_tsk_create(task3,0x10); //Create the second task and assign its priority
os_tsk_delete_self();
}
__task void task2 (void) //Define the function as an RTX task
{
os_itv_set (50); //Set an interval period of 500 Msec
while(1)
{
os_itv_wait (); //Wait for the interval period
GPIOPinWrite(LED_BASE, LED, 1);
}
}
__task void task3 (void)
{
os_itv_set (50); //Set an interval period of 500 Msec
while(1)
{
os_itv_wait (); //Wait for the interval period
GPIOPinWrite(LED_BASE, LED, 0); //Blink the low nibble LED's
}
}
int main (void)
{
LED_Init();
os_sys_init (task1);
}
此帖出自
小平头技术问答
一周热门 更多>