代码如下,下载后用jlink调试,发现任务一直没有被调用,第一次接触lpc1768,第一次用ucos,老师让一周完成任务,求高手赐教啊
#include "includes.h"
static OS_STK stkUartTask[256];
static OS_STK stkADCTask[256];
static OS_STK stkRTCTask[256];
#define UartTask_PRIO 4
#define ADCTask_PRIO 10
#define RTCTask_PRIO 6
OS_EVENT *Sem1;
uint32_t ADC_Data;
RTCTime local_time, alarm_time, current_time;
void UartTask(void *pvData)
{
INT8U err;
pvData=pvData;
UART0_Init ();
UART2_Init ();
UART3_Init ();
for(;;)
{
OSSemPend(Sem1,0,&err);
UART0_SendChar(current_time.RTC_Year);
UART0_SendString(" y ");
UART0_SendChar(current_time.RTC_Mon);
UART0_SendString(" m ");
UART0_SendChar(current_time.RTC_Yday);
UART0_SendString(" d ") ;
UART0_SendChar(current_time.RTC_Hour);
UART0_SendString(" h ");
UART0_SendChar(current_time.RTC_Min);
UART0_SendString(" m ");
UART0_SendChar(current_time.RTC_Sec);
UART0_SendString(" s");
UART0_SendByte(':');
UART0_SendByte(' ');
UART0_SendChar(ADC_Data);
UART0_SendByte('m');
UART0_SendByte('V');
UART0_SendByte('\n');
OSTimeDlyHMSM(0, 0, 0, 20);
/* UART3_SendChar(current_time.RTC_Year);
UART3_SendString(" y ");
UART3_SendChar(current_time.RTC_Mon);
UART3_SendString(" m ");
UART3_SendChar(current_time.RTC_Yday);
UART3_SendString(" d ") ;
UART3_SendChar(current_time.RTC_Hour);
UART3_SendString(" h ");
UART3_SendChar(current_time.RTC_Min);
UART3_SendString(" m ");
UART3_SendChar(current_time.RTC_Sec);
UART3_SendString(" s");
UART3_SendByte(':');
UART3_SendByte(' ');
UART3_SendChar(ADC_Data);
UART3_SendByte('m');
UART3_SendByte('V');
UART3_SendByte('\n'); */
}
}
void ADCTask(void *pvData)
{
uint32_t ADC_Buf = 0;
uint8_t i;
ADC_Init();
pvData=pvData;
for(;;)
{
for(i = 0;i < 8; i++)
{
ADC_Buf = ADC_Get();
ADC_Data += ADC_Buf;
}
ADC_Data = (ADC_Data / 8); /* 采样8次进行虑波处理 */
ADC_Data = (ADC_Data * 3300)/4096;
OSTimeDlyHMSM(0, 0, 0, 20);
}
}
void RTCTask(void *pvData)
{
unsigned char last_s=0;
pvData=pvData;
RTCInit();
RTCStart();
local_time.RTC_Sec = 0;
local_time.RTC_Min = 54;
local_time.RTC_Hour = 22;
local_time.RTC_Mday = 23;
local_time.RTC_Wday = 4;
local_time.RTC_Yday = 23; /* current date 05/12/2010 */
local_time.RTC_Mon = 12;
local_time.RTC_Year = 2012;
RTCSetTime( local_time ); /* Set local time */
for(;;)
{
if((current_time.RTC_Sec-last_s)>0)
{
last_s=current_time.RTC_Sec;
OSSemPost(Sem1);
}
OSTimeDlyHMSM(0, 0, 0, 20);
}
}
int main(void)
{
SystemInit();
OSInit();
Sem1=OSSemCreate(0);
OSTaskCreate(UartTask,(void *)0,&stkUartTask[255],4);
OSTaskCreate(ADCTask,(void *)0, &stkADCTask[255],10);
OSTaskCreate(RTCTask,(void *)0, &stkRTCTask[255],6);
OSStart();
}
|