嵌入式系统设计课设报告分析解析.docx

上传人:b****3 文档编号:4150093 上传时间:2022-11-28 格式:DOCX 页数:26 大小:24.06KB
下载 相关 举报
嵌入式系统设计课设报告分析解析.docx_第1页
第1页 / 共26页
嵌入式系统设计课设报告分析解析.docx_第2页
第2页 / 共26页
嵌入式系统设计课设报告分析解析.docx_第3页
第3页 / 共26页
嵌入式系统设计课设报告分析解析.docx_第4页
第4页 / 共26页
嵌入式系统设计课设报告分析解析.docx_第5页
第5页 / 共26页
点击查看更多>>
下载资源
资源描述

嵌入式系统设计课设报告分析解析.docx

《嵌入式系统设计课设报告分析解析.docx》由会员分享,可在线阅读,更多相关《嵌入式系统设计课设报告分析解析.docx(26页珍藏版)》请在冰豆网上搜索。

嵌入式系统设计课设报告分析解析.docx

嵌入式系统设计课设报告分析解析

福州大学

《嵌入式系统设计课设》

报告书

题目:

基于28027的虚拟系统

姓名:

学号:

学院:

电气工程与自动化学院

专业:

电气工程与自动化

年级:

起讫日期:

指导教师:

1、课程设计目的1

2、课程设计题目和实现目标1

3、设计方案1

4、程序流程图1

5、程序代码1

6、调试总结1

7、设计心得体会1

8、参考文献1

1、课程设计目的

《嵌入式系统设计课设》是与《嵌入式系统设计》课程相配套的实践教学环节。

《嵌入式系统设计》是一门实践性很强的专业基础课,通过课程设计,达到进一步理解嵌入式芯片的硬件、软件和综合应用方面的知识,培养实践能力和综合应用能力,开拓学习积极性、主动性,学会灵活运用已经学过的知识,并能不断接受新的知识。

培养大胆发明创造的设计理念,为今后就业打下良好的基础。

通过课程设计,掌握以下知识和技能:

1.嵌入式应用系统的总体方案的设计;

2.嵌入式应用系统的硬件设计;

3.嵌入式应用系统的软件程序设计;

4.嵌入式开发系统的应用和调试能力

2、课程设计题目和实现目标

课程设计题目:

基于28027的虚拟系统

任务要求:

A、利用28027的片上温度传感器,检测当前温度;

B、通过PWM过零中断作为温度检测A/D的触发,在PWM中断时完成温度采样和下一周期PWM占空比的修正;PWM频率为1K;

C、利用按键作为温度给定;温度给定变化从10度到40度。

D、当检测温度超过给定时,PWM占空比增减小(减小幅度自己设定);当检测温度小于给定时,PWM占空比增大(增大幅度自己设定);

E、把PWM输出接到捕获口,利用捕获口测量当前PWM的占空比;

F、把E测量的PWM占空比通过串口通信发送给上位机;

3、设计方案-----介绍系统实现方案和系统原理图

①系统实现方案:

任务A:

利用ADC模块通道A5获取当前环境温度。

任务B:

PWM过零触发ADC模块,在PWM中断服务函数中,将当前环境温度和按键设定温度进行比较,并按照任务D的要求修订PWM占空比。

PWM频率为1KHZ:

根据关系式:

TBCLK=SYSCLKOUT/(HSPCLKDIV*CLKDIV)

取SYSCLKOUT=60MHZ,HSPCLKDIV=6,CLKDIV=1,求得

TBCLK=10MHZ。

将period设为10K,便得到1KHZ的PWM波。

任务C:

用KEY模块的中断实现温度给定。

任务D:

在PWM的周期结束产生的中断中,通过改变比较点CMPA的位置来改变PWM占空比的大小。

任务E:

利用CAP模块设置3个捕获点捕获PWM的上升沿和下降沿,计算得到PWM波的占空比。

任务F:

利用SCI模块实现串口通信将温度和占空比上传到上位机。

此外,各模块的配置都与GPIO模块有关。

②系统原理图:

28027C2000PiccoloLaunchpad原理图

4、程序流程--------各个模块的流程图

5、程序代码

①/*app.c*/

//theincludes

#include"Application/app.h"

//**************************************************************************

//thedefines

//**************************************************************************

//theglobals

//**************************************************************************

//thefunctions

voiddelay(uint32_ttime)

{

while(time--);

}

//延时函数

//endoffile

②/*isr.c*/

//theincludes

#include"Application/isr.h"

//**************************************************************************

//thedefines

//**************************************************************************

//theglobals

//**************************************************************************

//thefunctions

interruptvoidLED_PWM_isr(void)//PWM的中断服务函数

{

if(MY_ADC

{

mycmp-=100*(SET_TEMP-MY_ADC);//PWM占空比增大

}

else

{

mycmp+=100*(MY_ADC-SET_TEMP);//环境检测温度大于设定温度

//PWM占空比减小

}

PWM_setCmpA(myPwm1,mycmp);//设定CmpA值

PWM_clearIntFlag(myPwm1);//清零PWM中断标志位

PIE_clearInt(myPie,PIE_GroupNumber_3);//清零PIE中断标志位

mycmp=5000;//将比较点初值设为5000

}

interruptvoidMY_ADC_isr(void)//ADC中断服务函数

{MY_ADC=ADC_readResult(myAdc,ADC_ResultNumber_0);

//获取ADC转换的数字量

MY_ADC=ADC_getTemperatureC(myAdc,MY_ADC);

//将数字量转换为温度值

ADC_clearIntFlag(myAdc,ADC_IntNumber_1);

//清除中断标志位

PIE_clearInt(myPie,PIE_GroupNumber_10);

}

interruptvoidKEY_xint1_isr(void)//按键中断服务函数

{

SET_TEMP++;

if(SET_TEMP>40)

{

SET_TEMP=10;

}

PIE_clearInt(myPie,PIE_GroupNumber_1);

}

interruptvoidMY_CAP_isr(void)//CAP中断服务函数

{

uint32_tCapEvent1Count=0,CapEvent2Count=0,CapEvent3Count=0;

floatfPwmDuty=0.0;

CapEvent1Count=CAP_getCap1(myCap);

CapEvent2Count=CAP_getCap2(myCap);

CapEvent3Count=CAP_getCap3(myCap);

fPwmDuty=(float)(CapEvent2Count-CapEvent1Count)/(CapEvent3Count-CapEvent1Count);//计算PWM占空比

fPwmDuty=fPwmDuty*100;

NOW_PWM=(int)fPwmDuty;

CAP_clearInt(myCap,CAP_Int_Type_CEVT3);

CAP_clearInt(myCap,CAP_Int_Type_Global);

//Acknowledgethisinterrupttoreceivemoreinterruptsfromgroup4

PIE_clearInt(myPie,PIE_GroupNumber_4);

}

//redefinedinIsr.h

//endoffile

①/*F2802x_Device.h*/

#include"F2802x_Component/include/adc.h"

#include"F2802x_Component/include/clk.h"

#include"F2802x_Component/include/flash.h"

#include"F2802x_Component/include/gpio.h"

#include"F2802x_Component/include/pie.h"

#include"F2802x_Component/include/pll.h"

#include"F2802x_Component/include/timer.h"

#include"F2802x_Component/include/wdog.h"

#include"F2802x_Component/include/sci.h"

#include"F2802x_Component/include/cap.h"

①/*Key.c*/

//theincludes

#include"User_Component/Key/Key.h"

//**************************************************************************

//thedefines

//**************************************************************************

//theglobals

//**************************************************************************

//thefunctions

//thefunctionprototypes

//!

\briefKEYinitail

//!

\param[in]None

//!

\param[out]None

voidKEY_initial(void)

{

}

//

//!

\briefKEYconfigure

//!

\param[in]None

//!

\param[out]None

voidKEY_config(void)

{//按键为GPIO12设置为输入口

//1.mode

GPIO_setMode(KEY_obj,KEY1,GPIO_12_Mode_GeneralPurpose);

//2.direction

GPIO_setDirection(KEY_obj,KEY1,GPIO_Direction_Input);

//3.pullup

GPIO_setPullUp(KEY_obj,KEY1,GPIO_PullUp_Disable);

//4.qualification

GPIO_setQualification(KEY_obj,KEY1,GPIO_Qual_Sync);

}

//!

\briefScanKeyAPI

//!

\param[in]key

//!

\param[out]thestateofKEY

uint16_tScanKey(constGPIO_Number_ekey)

{

returnGPIO_getData(KEY_obj,key);

}

//!

\param[in]None

//!

\param[out]None

voidKEY_INT_config(void)

{//(3).registerPIRvector

PIE_registerPieIntHandler(myPie,PIE_GroupNumber_1,PIE_SubGroupNumber_4,(intVec_t)&KEY_xint1_isr);

//(4).moduleinterruptconfigure

PIE_setExtIntPolarity(myPie,CPU_ExtIntNumber_1,PIE_ExtIntPolarity_FallingEdge);

GPIO_setExtInt(myGpio,GPIO_Number_12,CPU_ExtIntNumber_1);

//(5).enablemoduleIE

PIE_enableExtInt(myPie,CPU_ExtIntNumber_1);

//(6).enablePIEIERx.y

PIE_enableInt(myPie,PIE_GroupNumber_1,PIE_InterruptSource_XINT_1);

//(7)enableCPUIERx

CPU_enableInt(myCpu,CPU_IntNumber_1);

}

//

//!

\briefInterruptServiceRoutine

//!

\param[in]None

//!

\param[out]None

TARGET_EXTinterruptvoidKEY_xint1_isr(void);//redefinedinIsr.h

//endoffile

/*Key.h*/

#ifndef_KEY_H_

#define_KEY_H_

//theincludes

#include

//driver

#include"F2802x_Component/F2802x_Device.h"

#include"User_Component/User_Mcu/User_System.h"

#ifdef__cplusplus

extern"C"{

#endif

#ifndefTARGET_GLOBAL

#defineTARGET_EXTextern

#else

#defineTARGET_EXT

#endif

/*-------hardwaredescriptionoftheexamplemodule-------------*/

//Forexample

//ThemodulederivedfromGPIO

#defineKEY_objmyGpio//heremyGpioisdefinedinSystem.h

#defineKEY1GPIO_Number_12//pin

TARGET_EXTvoidKEY_initial(void);

TARGET_EXTvoidKEY_config(void);

TARGET_EXTvoidKEY_INT_config(void);

TARGET_EXTinterruptvoidKEY_xint1_isr(void);//redefinedinIsr.h

/*-------endofhardwaredescription-------------*/

TARGET_EXTuint16_tScanKey(constGPIO_Number_ekey);

/*-------endofAPIdescription-------------*/

#defineKEYPressed1

/*-------endofdefines-------------*/

#ifdef__cplusplus

}

#endif//extern"C"

#endif//endof_EXAMPLE_H_definition

②/*LED_PWM.c*/

//theincludes

#include"User_Component/LED_PWM/LED_PWM.h"

//thefunctions

voidLED_PWM_initial(void)

{

mycmp=0;

}

voidLED_PWM_config(void)

{

//GPIO的配置

GPIO_setMode(myGpio,GPIO_Number_0,GPIO_0_Mode_EPWM1A);

GPIO_setPullUp(myGpio,GPIO_Number_0,GPIO_PullUp_Disable);

//PWM的配置

CLK_disableTbClockSync(myClk);

//PWM模块使能

CLK_enablePwmClock(myClk,PWM_Number_1);

//设置PWM的时钟

//PWM_setClkDiv(myPwm1,PWM_ClkDiv_by_1);

PWM_setHighSpeedClkDiv(myPwm1,PWM_HspClkDiv_by_6);

//计数器的设置

PWM_setCounterMode(myPwm1,PWM_CounterMode_Up);

//PWM周期设置

PWM_setPeriod(myPwm1,10000);

//设置周期加载模式

PWM_setPeriodLoad(myPwm1,PWM_PeriodLoad_Shadow);

//比较点的设置

PWM_setCmpA(myPwm1,5000);

//PWM装载模式

PWM_setLoadMode_CmpA(myPwm1,PWM_LoadMode_Period);

//动作

PWM_setActionQual_CntUp_CmpA_PwmA(myPwm1,PWM_ActionQual_Set);

PWM_setActionQual_Period_PwmA(myPwm1,PWM_ActionQual_Clear);

//时钟同步

CLK_enableTbClockSync(myClk);

}

voidLED_PWM_INT_config(void)

{

PIE_registerPieIntHandler(myPie,PIE_GroupNumber_3,PIE_SubGroupNumber_1,(intVec_t)&(LED_PWM_isr));

//模块中断配置

PWM_setIntMode(myPwm1,PWM_IntMode_CounterEqualPeriod);

PWM_setIntPeriod(myPwm1,PWM_IntPeriod_FirstEvent);

//PWM中断使能

PWM_enableInt(myPwm1);

//PIE开关的允许

PIE_enableInt(myPie,PIE_GroupNumber_3,PIE_InterruptSource_EPWM1);

//CPU全局中断

CPU_enableInt(myCpu,CPU_IntNumber_3);

}

//endoffile

/LED_PWM.h*/

#ifndef_LED_PWM_H_

#define_LED_PWM_H_

//theincludes

#include

//driver

#include"F2802x_Component/F2802x_Device.h"

#include"User_Component/User_Mcu/User_System.h"

#ifdef__cplusplus

extern"C"{

#endif

#ifndefTARGET_GLOBAL

#defineTARGET_EXTextern

#else

#defineTARGET_EXT

#endif

/*-------hardwaredescriptionoftheexamplemodule-------------*/

TARGET_EXTvoidLED_PWM_initial(void);

TARGET_EXTvoidLED_PWM_config(void);

TARGET_EXTvoidLED_PWM_INT_config(void);

TARGET_EXTinterruptvoidLED_PWM_isr(void);//redefinedinIsr.h

/*-------endofhardwaredescription-------------*/

TARGET_EXTuint16_tmycmp;

#ifdef__cplusplus

}

#endif//extern"C"

#endif//endof_EXAMPLE_H_definition

③/*MY_ADC.c*/

//theincludes

#include"User_Component/MY_ADC/MY_ADC.h"

//thefunctions

voidMY_ADC_initial(void)

{

SET_TEMP=30;//初始设定温度为30摄氏度

}

voidMY_ADC_config(void)

{//ADC时钟使能

CLK_enableAdcClock(myClk);

//初始化ADC模块

ADC_setVoltRefSrc(myAdc,ADC_VoltageRefSrc_Int);

ADC_powerUp(myAdc);

ADC_enableBandGap(myAdc);

ADC_enableRefBuffers(myAdc);

ADC_enable(myAdc);

//温度转换使能

ADC_enableTempSensor(myAdc);

//soc配置

ADC_setSocChanNumber(myAdc,ADC_SocNumber_0,ADC_SocChanNumber_A5);

ADC_setSocSampleWindow(myAdc,ADC_SocNumber_0,ADC_SocSampleWindow_7_cycles);

ADC_setSocTrigSrc(myAdc,ADC_SocNumber_0,ADC_SocTrigSrc_EPWM1_ADCSOCA);

//PWM配置

PWM_setSocAPulseSrc(myPwm1,PWM_SocPulseSrc_CounterEqualZero);

PWM_setSocAPeriod(myPwm1,PWM_SocPeriod_FirstEvent);

PWM_enableSocAPulse(myPwm1);

}

voidMY_ADC_INT_config(void)

{

PIE_registerPieIntHandler(myPie,PIE_GroupNumber_10,PIE_SubGroupNumber_1,(intVec_t)&(

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1