收藏 分销(赏)

嵌入式专业系统设计课设报告.doc

上传人:精*** 文档编号:3033288 上传时间:2024-06-13 格式:DOC 页数:43 大小:566.54KB
下载 相关 举报
嵌入式专业系统设计课设报告.doc_第1页
第1页 / 共43页
嵌入式专业系统设计课设报告.doc_第2页
第2页 / 共43页
嵌入式专业系统设计课设报告.doc_第3页
第3页 / 共43页
嵌入式专业系统设计课设报告.doc_第4页
第4页 / 共43页
嵌入式专业系统设计课设报告.doc_第5页
第5页 / 共43页
点击查看更多>>
资源描述

1、福州大学嵌入式系统设计课设汇报书题 目: 基于28027虚拟系统 姓 名: 学 号: 学 院: 电气工程和自动化学院 专 业: 电气工程和自动化 年 级: 起讫日期: 指导老师: 目 录1、课程设计目标12、课程设计题目和实现目标13、设计方案14、程序步骤图15、程序代码16、调试总结17、设计心得体会18、参考文件11、课程设计目标嵌入式系统设计课设是和嵌入式系统设计课程相配套实践教学步骤。嵌入式系统设计是一门实践性很强专业基础课,经过课程设计,达成深入了解嵌入式芯片硬件、软件和综合应用方面知识,培养实践能力和综合应用能力,开拓学习主动性、主动性,学会灵活利用已经学过知识,并能不停接收新知

2、识。培养大胆发明发明设计理念,为以后就业打下良好基础。经过课程设计,掌握以下知识和技能:1 嵌入式应用系统总体方案设计;2 嵌入式应用系统硬件设计;3 嵌入式应用系统软件程序设计;4 嵌入式开发系统应用和调试能力 2、 课程设计题目和实现目标 课程设计题目:基于28027虚拟系统任务要求:A、 利用28027片上温度传感器,检测目前温度;B、 经过PWM过零中止作为温度检测A/D触发,在PWM中止时完成温度采样和下一周期PWM占空比修正;PWM频率为1K;C、 利用按键作为温度给定;温度给定改变从10度到40度。D、 当检测温度超出给定时,PWM占空比增减小(减小幅度自己设定);当检测温度小于

3、给定时,PWM占空比增大(增大幅度自己设定);E、 把PWM输出接到捕捉口,利用捕捉口测量目前PWM占空比;F、 把E测量PWM占空比经过串口通信发送给上位机;3、 设计方案-介绍系统实现方案和系统原理图系统实现方案:任务A:利用ADC模块通道A5获取目前环境温度。任务B:PWM过零触发ADC模块,在PWM中止服务函数中,将目前环境温度和按键设定温度进行比较,并根据任务D要求修订PWM占空比。PWM频率为1K HZ:依据关系式:TBCLK=SYSCLKOUT/(HSPCLKDIV*CLKDIV)取SYSCLKOUT=60M HZ,HSPCLKDIV=6,CLKDIV=1,求得TBCLK=10M

4、 HZ。将period设为10K,便得到1K HZ PWM波。任务C:用KEY模块中止实现温度给定。任务D:在PWM周期结束产生中止中,经过改变比较点CMPA位置来改变PWM占空比大小。任务E:利用CAP模块设置3个捕捉点捕捉PWM上升沿和下降沿,计算得到PWM波占空比。任务F:利用SCI模块实现串口通信将温度和占空比上传到上位机。另外,各模块配置全部和GPIO模块相关。系统原理图:28027 C Piccolo Launchpad原理图4、 程序步骤-各个模块步骤图5、 程序代码/*app.c*/ the includes#include Application/app.h/ */ the

5、defines/ */ the globals/ */ the functions void delay(uint32_t time) while(time-); /延时函数/ end of file/*isr.c*/ the includes#include Application/isr.h/ */ the defines/ */ the globals/ */ the functionsinterrupt void LED_PWM_isr(void) /PWM中止服务函数if(MY_ADC40)SET_TEMP=10;PIE_clearInt(myPie,PIE_GroupNumber_

6、1);interrupt void MY_CAP_isr(void) /CAP中止服务函数uint32_t CapEvent1Count=0,CapEvent2Count=0,CapEvent3Count=0;float fPwmDuty=0.0; CapEvent1Count = CAP_getCap1(myCap); CapEvent2Count = CAP_getCap2(myCap); CapEvent3Count = CAP_getCap3(myCap); fPwmDuty = (float)(CapEvent2Count - CapEvent1Count) / (CapEvent3

7、Count - CapEvent1Count); /计算PWM占空比 fPwmDuty=fPwmDuty*100; NOW_PWM=(int)fPwmDuty; CAP_clearInt(myCap, CAP_Int_Type_CEVT3); CAP_clearInt(myCap, CAP_Int_Type_Global); / Acknowledge this interrupt to receive more interrupts from group 4 PIE_clearInt(myPie, PIE_GroupNumber_4);/redefined in Isr.h/ end of

8、file/*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

9、.h#include F2802x_Component/include/wdog.h#include F2802x_Component/include/sci.h#include F2802x_Component/include/cap.h/*Key.c*/ the includes#include User_Component/Key/Key.h/ */ the defines/ */ the globals/ */ the functions/ the function prototypes/! brief KEY initail/! paramin None/! paramout Non

10、evoid KEY_initial(void)/! brief KEY configure/! paramin None/! paramout Nonevoid KEY_config(void) /按键为GPIO12设置为输入口 /1. modeGPIO_setMode(KEY_obj, KEY1, GPIO_12_Mode_GeneralPurpose);/2. directionGPIO_setDirection(KEY_obj, KEY1, GPIO_Direction_Input);/3. pullupGPIO_setPullUp(KEY_obj, KEY1, GPIO_PullUp_

11、Disable);/4. qualificationGPIO_setQualification(KEY_obj, KEY1, GPIO_Qual_Sync); /! brief ScanKey API/! paramin key/! paramout the state of KEYuint16_t ScanKey(const GPIO_Number_e key)return GPIO_getData(KEY_obj, key);/! paramin None/! paramout Nonevoid KEY_INT_config(void) /(3). register PIR vectorP

12、IE_registerPieIntHandler(myPie, PIE_GroupNumber_1, PIE_SubGroupNumber_4, (intVec_t) &KEY_xint1_isr);/(4). module interrupt configurePIE_setExtIntPolarity(myPie,CPU_ExtIntNumber_1, PIE_ExtIntPolarity_FallingEdge);GPIO_setExtInt(myGpio, GPIO_Number_12, CPU_ExtIntNumber_1);/(5). enable module IEPIE_ena

13、bleExtInt(myPie, CPU_ExtIntNumber_1);/(6). enable PIEIERx.yPIE_enableInt(myPie, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1);/(7) enable CPU IERxCPU_enableInt(myCpu, CPU_IntNumber_1);/! brief Interrupt Service Routine/! paramin None/! paramout NoneTARGET_EXT interrupt void KEY_xint1_isr(void); /re

14、defined in Isr.h/ end of file/*Key.h*/#ifndef _KEY_H_#define _KEY_H_/ the includes#include / driver#include F2802x_Component/F2802x_Device.h#include User_Component/User_Mcu/User_System.h#ifdef _cplusplusextern C #endif#ifndef TARGET_GLOBAL #define TARGET_EXT extern#else #define TARGET_EXT#endif/*- h

15、ardware description of the example module -*/ For example/ The module derived from GPIO#define KEY_obj myGpio /here myGpio is defined in System.h#define KEY1 GPIO_Number_12 /pinTARGET_EXT void KEY_initial(void);TARGET_EXT void KEY_config(void);TARGET_EXT void KEY_INT_config(void);TARGET_EXT interrup

16、t void KEY_xint1_isr(void); /redefined in Isr.h/*-end of hardware description -*/TARGET_EXT uint16_t ScanKey(const GPIO_Number_e key);/*-end of API description -*/#define KEYPressed 1/*- end of defines -*/#ifdef _cplusplus#endif / extern C#endif / end of _EXAMPLE_H_ definition/*LED_PWM.c*/ the inclu

17、des#include User_Component/LED_PWM/LED_PWM.h/ the functions void LED_PWM_initial(void) mycmp=0; void LED_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_enable

18、PwmClock(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

19、(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); void LED_PWM_INT_config(void) PIE_registerPieIntHandler(myPie,PI

20、E_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_e

21、nableInt(myCpu,CPU_IntNumber_3); / end of file/LED_PWM.h*/#ifndef _LED_PWM_H_#define _LED_PWM_H_/ the includes#include / driver#include F2802x_Component/F2802x_Device.h#include User_Component/User_Mcu/User_System.h#ifdef _cplusplusextern C #endif#ifndef TARGET_GLOBAL #define TARGET_EXT extern#else #

22、define TARGET_EXT#endif/*- hardware description of the example module -*/TARGET_EXT void LED_PWM_initial(void);TARGET_EXT void LED_PWM_config(void);TARGET_EXT void LED_PWM_INT_config(void);TARGET_EXT interrupt void LED_PWM_isr(void); /redefined in Isr.h/*-end of hardware description -*/TARGET_EXT ui

23、nt16_t mycmp;#ifdef _cplusplus#endif / extern C#endif / end of _EXAMPLE_H_ definition/*MY_ADC.c*/ the includes#include User_Component/MY_ADC/MY_ADC.h/ the functionsvoid MY_ADC_initial(void)SET_TEMP=30; /初始设定温度为30摄氏度void MY_ADC_config(void) /ADC时钟使能 CLK_enableAdcClock(myClk);/初始化ADC模块 ADC_setVoltRefS

24、rc(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_SocSample

25、Window_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);void MY_ADC_INT_config(void)PIE_registerPieIntHandler(myPie,

26、PIE_GroupNumber_10,PIE_SubGroupNumber_1,(intVec_t)&(MY_ADC_isr); /模块中止配置 ADC_setIntPulseGenMode(myAdc, ADC_IntPulseGenMode_Prior); ADC_setIntSrc(myAdc,ADC_IntNumber_1, ADC_IntSrc_EOC0); ADC_setIntMode(myAdc, ADC_IntNumber_1, ADC_IntMode_ClearFlag); /ADC中止使能 ADC_enableInt(myAdc,ADC_IntNumber_1); /PIE

27、开关许可 PIE_enableInt(myPie, PIE_GroupNumber_10, PIE_InterruptSource_ADCINT_10_1); /CPU全局中止 CPU_enableInt(myCpu,CPU_IntNumber_10); / end of file/*MY_ADC.h*/#ifndef _MY_ADC_H_#define _MY_ADC_H_/ the includes#include / driver#include F2802x_Component/F2802x_Device.h#include User_Component/User_Mcu/User_S

28、ystem.h#ifdef _cplusplusextern C #endif#ifndef TARGET_GLOBAL #define TARGET_EXT extern#else #define TARGET_EXT#endif/*- hardware description of the example module -*/TARGET_EXT void MY_ADC_initial(void);TARGET_EXT void MY_ADC_config(void);TARGET_EXT void MY_ADC_INT_config(void);TARGET_EXT interrupt

29、void MY_ADC_isr(void); /redefined in Isr.h/*-end of hardware description -*/TARGET_EXT uint16_t MY_ADC;TARGET_EXT uint16_t SET_TEMP;/*- end of globals -*/#ifdef _cplusplus#endif / extern C#endif / end of _EXAMPLE_H_ definition/*MY_CAP.c*/ the includes#include User_Component/MY_CAP/MY_CAP.h#include U

30、ser_Component/User_Mcu/User_System.h void MY_CAP_initial(void)void MY_CAP_config(void)GPIO_setPullUp(myGpio, GPIO_Number_5, GPIO_PullUp_Enable);GPIO_setQualification(myGpio, GPIO_Number_5, GPIO_Qual_Sync); GPIO_setMode(myGpio, GPIO_Number_5, GPIO_5_Mode_ECAP1); CLK_enableEcap1Clock(myClk); CAP_disab

31、leInt(myCap, CAP_Int_Type_All); / 严禁CAP中止 CAP_clearInt(myCap, CAP_Int_Type_All); / 清除CAP中止标志位 CAP_disableCaptureLoad(myCap); / Disable CAP1-CAP4 register loads CAP_disableTimestampCounter(myCap); / Make sure the counter is stopped / Configure peripheral registers CAP_setCapContinuous(myCap); / conti

32、nuous CAP_setStopWrap(myCap, CAP_Stop_Wrap_CEVT4);/ Stop at 3 events CAP_setCapEvtPolarity(myCap, CAP_Event_1, CAP_Polarity_Rising); / 捕捉上升沿 CAP_setCapEvtPolarity(myCap, CAP_Event_2, CAP_Polarity_Falling); / 捕捉下降沿 CAP_setCapEvtPolarity(myCap, CAP_Event_3, CAP_Polarity_Rising); / 捕捉上升沿 CAP_setCapEvtR

33、eset(myCap, CAP_Event_3, CAP_Reset_Enable); / 重置计数器确保计数器不会溢出 CAP_enableTimestampCounter(myCap); / 打开计数器 CAP_enableCaptureLoad(myCap); / Enable CAP1-CAP4 register loads /* CAP_enableInt(myCap, CAP_Int_Type_CEVT3); / 3个捕捉点以后发生中止 / Register interrupt handlers in the PIE vector table PIE_registerPieIntH

34、andler(myPie, PIE_GroupNumber_4, PIE_SubGroupNumber_1, (intVec_t)&ecap1_isr); / Enable CPU INT4 which is connected to ECAP1-4 INT:CPU_enableInt(myCpu, CPU_IntNumber_4); / Enable eCAP INTn in the PIE: Group 3 interrupt 1-6 PIE_enableCaptureInt(myPie); CPU_enableGlobalInts(myCpu); */void MY_CAP_INT_co

35、nfig(void) CAP_enableInt(myCap, CAP_Int_Type_CEVT3); / 3 events = interrupt / Register interrupt handlers in the PIE vector table PIE_registerPieIntHandler(myPie, PIE_GroupNumber_4, PIE_SubGroupNumber_1, (intVec_t)&MY_CAP_isr); / Enable CPU INT4 which is connected to ECAP1-4 INT:CPU_enableInt(myCpu,

36、 CPU_IntNumber_4); / Enable eCAP INTn in the PIE: Group 3 interrupt 1-6 PIE_enableCaptureInt(myPie); CPU_enableGlobalInts(myCpu);/ end of file/*MY_CAP.h*/#ifndef _MY_CAP_H_#define _MY_CAP_H_/ the includes#include / driver#include F2802x_Component/F2802x_Device.h#ifdef _cplusplusextern C #endif#ifndef TARGET_GLOBAL #define TARGET_EXT extern#else #define TARGET_EXT#endif/*- hardware description of the example module -*/TARGET_EXT void MY_CAP_initial(void);TARGET_EXT void MY_CAP_con

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
搜索标签

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服