This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EK-TM4C123GXL: 关于ucos关中断实验的编译错误

Part Number: EK-TM4C123GXL

我是一个初学者,现在在学用丁山教授的书学习ucos,软件用ccs,板子用tm4c123gxl。

在进行书本上测量内核关中断时间和最简单的开关中断程序中,主程序没有编译没有问题,但是在编译整个工程的时候出现了几个错误,在网上找了很多都很难解决。如能帮助,甚是感谢。

下面是我的代码以及运行结果

1.开关中断

int function(int p1)
{
    OS_ENTER_CRITICAL();/*进入临界区,不允许任务切换*/
    /*访问临界资源代码段*/
    OS_EXIT_CRITICAL();/*离开临界区,允许任务切换*/
    /*其他代码*/
}

主函数编译结果

工程编译结果

2.测量内核关中断时间

#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include "driverlib/sysctl.h"
#include <ucos_ii.h>
#include <cpu.h>
int main (void)
{
    /*定时器初始化,获得50Mhz的分频,这里采用的是系统定时器SysTick*/
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
    INT8U i,j,k;
    INT32U cnts,start,end,sum=0,test_start,test_end,test_sum=0, period=0, F=0,real_time=0;
    FP32 t=0,final_time=0;
    cnts = (INT32U)SysCtlClockGet()/100; /*获得定时器的装载值*/
    F=SysCtlClockGet(); /*获得系统定时器的时钟频率*/
    printf("Basic Frequency=%d\n",F); /*输出系统的时钟频率*/
    SysTickPeriodSet(cnts); /*设置定时器的装载值*/
    SysTickEnable();
#if OS_CRITICAL_METHOD == 3u /*采用第3种进入临界段的处理方法*/
    OS_CPU_SR cpu_sr = 0u;
#endif
    for(i=0;i<10;i++) /*计算读取定时器语句所消耗的时间,计算10次,取其平均值*/
    {
        start=SysTickValueGet();
        end=SysTickValueGet();
        sum=sum+start-end;
        //printf("start_time=%d,end_time=%d\n",start,end); /*输出开始和结束时间*/

    }
    sum=sum/10;
    //printf("everage_time=%d\n",sum); /*输出平均时间*/
    for(j=0;j<10;j++) /*计算读取关中断时间,计算10次,取其平均值*/
    {
        test_start=SysTickValueGet(); /*读取关中断的开始时间*/
        OS_ENTER_CRITICAL(); /*关中断*/
        for(k=0;k<1000;k++) /*模拟关中断中的系统操作*/
            OS_EXIT_CRITICAL(); /*开中断*/
        test_end=SysTickValueGet(); /*读取关中断的结束时间*/
        if(test_start>test_end)
        { /*计算关中断时间*/
            period=test_start-test_end;
        }
        else
        {
            period=test_start+cnts-test_end;
            }
        //printf("period=======%d\n",flag); /*输出每次计算的关中断时间*/
        test_sum+=period;
        //printf("test_start_time=%d,test_end_time=%d\n",test_start,test_end); /*输出开始和结束时间*/
        }
    test_sum=test_sum/10; /*计算平均时间*/
    //printf("test_everage_time=%d\n",test_sum); /*输出平均时间*/
    real_time=test_sum-sum; /*计算真实时间,关中断时间减去读取定时器所消耗的时间*/
    //printf("Real_time=test_everage_time-everage_time=%d-%d=%d\n",test_sum,sum,real_time); /*输出真实时间*/
    t=1000000.0/F; /*计算时钟间隔*/
    final_time=real_time*t; /*计算最终时间*/
    printf("Final time=Real_time*t=%d*%0.2f=%0.2fus\n",real_time,t,final_time); /*输出最终时间,单位是μs*/
    }

主函数编译结果

工程编译结果

 workspace_v6_0.rar