嵌入式计算机课程设计,嵌入式系统设计课设报告.doc

253b171540df25e1b84436cbe50dfc72.gif嵌入式系统设计课设报告.doc

福州大学嵌入式系统设计课设报告书题 目 基于28027的虚拟系统 姓 名 学 号 学 院 电气工程与自动化学院 专 业 电气工程与自动化 年 级 起讫日期 指导教师 目 录1、课程设计目的12、课程设计题目和实现目标13、设计方案14、程序流程图15、程序代码16、调试总结17、设计心得体会18、参考文献11、课程设计目的嵌入式系统设计课设是与嵌入式系统设计课程相配套的实践教学环节。嵌入式系统设计是一门实践性很强的专业基础课,通过课程设计,达到进一步理解嵌入式芯片的硬件、软件和综合应用方面的知识,培养实践能力和综合应用能力,开拓学习积极性、主动性,学会灵活运用已经学过的知识,并能不断接受新的知识。培养大胆发明创造的设计理念,为今后就业打下良好的基础。通过课程设计,掌握以下知识和技能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获取当前环境温度。任务BPWM过零触发ADC模块,在PWM中断服务函数中,将当前环境温度和按键设定温度进行比较,并按照任务D的要求修订PWM占空比。PWM频率为1K HZ根据关系式TBCLKSYSCLKOUT/(HSPCLKDIV*CLKDIV取SYSCLKOUT60M HZ,HSPCLKDIV6,CLKDIV1,求得TBCLK10M HZ。将period设为10K,便得到1K HZ 的PWM波。任务C用KEY模块的中断实现温度给定。任务D在PWM的周期结束产生的中断中,通过改变比较点CMPA的位置来改变PWM占空比的大小。任务E利用CAP模块设置3个捕获点捕获PWM的上升沿和下降沿,计算得到PWM波的占空比。任务F利用SCI模块实现串口通信将温度和占空比上传到上位机。此外,各模块的配置都与GPIO模块有关。系统原理图28027 C2000 Piccolo Launchpad原理图4、 程序流程各个模块的流程图5、 程序代码/*app.c*/ the includesinclude Application/app.h the defines the globals the functions void delayuint32_t time whiletime; 延时函数 end of file/*isr.c*/ the includesinclude Application/isr.h the defines the globals the functionsinterrupt void LED_PWM_isrvoid PWM的中断服务函数ifMY_ADCSET_TEMP 环境检测温度小于设定温度时mycmp-100*SET_TEMP-MY_ADC; PWM占空比增大elsemycmp100*MY_ADC-SET_TEMP; 环境检测温度大于设定温度 PWM占空比减小 PWM_setCmpAmyPwm1,mycmp; 设定CmpA值 PWM_clearIntFlagmyPwm1; 清零PWM中断标志位 PIE_clearIntmyPie,PIE_GroupNumber_3; 清零PIE中断标志位 mycmp5000; 将比较点初值设为5000interrupt void MY_ADC_isrvoid ADC中断服务函数 MY_ADCADC_readResultmyAdc,ADC_ResultNumber_0; 获取ADC转换的数字量 MY_ADC ADC_getTemperatureCmyAdc, MY_ADC;将数字量转换为温度值ADC_clearIntFlagmyAdc, ADC_IntNumber_1;清除中断标志位PIE_clearIntmyPie,PIE_GroupNumber_10;interrupt void KEY_xint1_isrvoid 按键中断服务函数SET_TEMP;ifSET_TEMP40SET_TEMP10;PIE_clearIntmyPie,PIE_GroupNumber_1;interrupt void MY_CAP_isrvoid CAP中断服务函数uint32_t CapEvent1Count0,CapEvent2Count0,CapEvent3Count0;float fPwmDuty0.0; CapEvent1Count CAP_getCap1myCap; CapEvent2Count CAP_getCap2myCap; CapEvent3Count CAP_getCap3myCap; fPwmDuty floatCapEvent2Count - CapEvent1Count / CapEvent3Count - CapEvent1Count; 计算PWM占空比 fPwmDutyfPwmDuty*100; NOW_PWMintfPwmDuty; CAP_clearIntmyCap, CAP_Int_Type_CEVT3; CAP_clearIntmyCap, CAP_Int_Type_Global; Acknowledge this interrupt to receive more interrupts from group 4 PIE_clearIntmyPie, PIE_GroupNumber_4;redefined in Isr.h end of file/*F2802x_Device.h*/ include F2802x_Component/include/adc.hinclude F2802x_Component/include/clk.hinclude F2802x_Component/include/flash.hinclude F2802x_Component/include/gpio.hinclude F2802x_Component/include/pie.hinclude F2802x_Component/include/pll.hinclude F2802x_Component/include/timer.hinclude F2802x_Component/include/wdog.hinclude F2802x_Component/include/sci.hinclude F2802x_Component/include/cap.h/*Key.c*/ the includesinclude User_Component/Key/Key.h the defines the globals the functions the function prototypes brief KEY initail paramin None paramout Nonevoid KEY_initialvoid brief KEY configure paramin None paramout Nonevoid KEY_configvoid 按键为GPIO12设置为输入口 1. modeGPIO_setModeKEY_obj, KEY1, GPIO_12_Mode_GeneralPurpose;2. directionGPIO_setDirectionKEY_obj, KEY1, GPIO_Direction_;3. pullupGPIO_setPullUpKEY_obj, KEY1, GPIO_PullUp_Disable;4. qualificationGPIO_setQualificationKEY_obj, KEY1, GPIO_Qual_Sync; brief ScanKey API paramin key paramout the state of KEYuint16_t ScanKeyconst GPIO_Number_e keyreturn GPIO_getDataKEY_obj, key; paramin None paramout Nonevoid KEY_INT_configvoid 3. register PIR vectorPIE_registerPieIntHandlermyPie, PIE_GroupNumber_1, PIE_SubGroupNumber_4, intVec_t 4. module interrupt configurePIE_setExtIntPolaritymyPie,CPU_ExtIntNumber_1, PIE_ExtIntPolarity_FallingEdge;GPIO_setExtIntmyGpio, GPIO_Number_12, CPU_ExtIntNumber_1;5. enable module IEPIE_enableExtIntmyPie, CPU_ExtIntNumber_1;6. enable PIEIERx.yPIE_enableIntmyPie, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1;7 enable CPU IERxCPU_enableIntmyCpu, CPU_IntNumber_1; brief Interrupt Service Routine paramin None paramout NoneTARGET_EXT interrupt void KEY_xint1_isrvoid; redefined in Isr.h end of file/*Key.h*/ifndef _KEY_H_define _KEY_H_ the includesinclude stdint.h driverinclude F2802x_Component/F2802x_Device.hinclude User_Component/User_Mcu/User_System.hifdef cplusplusextern C endififndef TARGET_GLOBAL define TARGET_EXT externelse define TARGET_EXTendif/*- hardware description of the example module -*/ For example The module derived from GPIOdefine KEY_obj myGpio here myGpio is defined in System.hdefine KEY1 GPIO_Number_12 pinTARGET_EXT void KEY_initialvoid;TARGET_EXT void KEY_configvoid;TARGET_EXT void KEY_INT_configvoid;TARGET_EXT interrupt void KEY_xint1_isrvoid; redefined in Isr.h/*-end of hardware description -*/TARGET_EXT uint16_t ScanKeyconst GPIO_Number_e key;/*-end of API description -*/define KEYPressed 1/*- end of defines -*/ifdef cplusplusendif extern Cendif end of _EXAMPLE_H_ definition/*LED_PWM.c*/ the includesinclude User_Component/LED_PWM/LED_PWM.h the functions void LED_PWM_initialvoid mycmp0; void LED_PWM_configvoid GPIO的配置 GPIO_setModemyGpio,GPIO_Number_0,GPIO_0_Mode_EPWM1A; GPIO_setPullUpmyGpio,GPIO_Number_0,GPIO_PullUp_Disable; PWM的配置 CLK_disableTbClockSyncmyClk; PWM模块使能 CLK_enablePwmClockmyClk,PWM_Number_1; 设置PWM的时钟 PWM_setClkDivmyPwm1,PWM_ClkDiv_by_1; PWM_setHighSpeedClkDivmyPwm1, PWM_HspClkDiv_by_6; 计数器的设置 PWM_setCounterModemyPwm1,PWM_CounterMode_Up; PWM周期设置 PWM_setPeriodmyPwm1,10000; 设置周期加载模式 PWM_setPeriodLoadmyPwm1,PWM_PeriodLoad_Shadow; 比较点的设置 PWM_setCmpAmyPwm1,5000; PWM装载模式 PWM_setLoadMode_CmpAmyPwm1,PWM_LoadMode_Period; 动作 PWM_setActionQual_CntUp_CmpA_PwmAmyPwm1,PWM_ActionQual_Set; PWM_setActionQual_Period_PwmAmyPwm1,PWM_ActionQual_Clear; 时钟同步 CLK_enableTbClockSyncmyClk; void LED_PWM_INT_configvoid PIE_registerPieIntHandlermyPie,PIE_GroupNumber_3,PIE_SubGroupNumber_1,intVec_t 模块中断配置 PWM_setIntModemyPwm1,PWM_IntMode_CounterEqualPeriod; PWM_setIntPeriodmyPwm1,PWM_IntPeriod_FirstEvent; PWM中断使能 PWM_enableIntmyPwm1; PIE开关的允许 PIE_enableIntmyPie, PIE_GroupNumber_3, PIE_InterruptSource_EPWM1; CPU全局中断 CPU_enableIntmyCpu,CPU_IntNumber_3; end of file/LED_PWM.h*/ifndef _LED_PWM_H_define _LED_PWM_H_ the includesinclude stdint.h driverinclude F2802x_Component/F2802x_Device.hinclude User_Component/User_Mcu/User_System.hifdef cplusplusextern C endififndef TARGET_GLOBAL define TARGET_EXT externelse define TARGET_EXTendif/*- hardware description of the example module -*/TARGET_EXT void LED_PWM_initialvoid;TARGET_EXT void LED_PWM_configvoid;TARGET_EXT void LED_PWM_INT_configvoid;TARGET_EXT interrupt void LED_PWM_isrvoid; redefined in Isr.h/*-end of hardware description -*/TARGET_EXT uint16_t mycmp;ifdef cplusplusendif extern Cendif end of _EXAMPLE_H_ definition/*MY_ADC.c*/ the includesinclude User_Component/MY_ADC/MY_ADC.h the functionsvoid MY_ADC_initialvoidSET_TEMP30; 初始设定温度为30摄氏度void MY_ADC_configvoid ADC时钟使能 CLK_enableAdcClockmyClk;初始化ADC模块 ADC_setVoltRefSrcmyAdc, ADC_VoltageRefSrc_Int; ADC_powerUpmyAdc; ADC_enableBandGapmyAdc; ADC_enableRefBuffersmyAdc; ADC_enablemyAdc; 温度转换使能 ADC_enableTempSensormyAdc; soc配置 ADC_setSocChanNumbermyAdc, ADC_SocNumber_0, ADC_SocChanNumber_A5; ADC_setSocSampleWindowmyAdc, ADC_SocNumber_0, ADC_SocSampleWindow_7_cycles; ADC_setSocTrigSrcmyAdc, ADC_SocNumber_0, ADC_SocTrigSrc_EPWM1_ADCSOCA; PWM配置 PWM_setSocAPulseSrcmyPwm1,PWM_SocPulseSrc_CounterEqualZero; PWM_setSocAPeriodmyPwm1,PWM_SocPeriod_FirstEvent; PWM_enableSocAPulsemyPwm1;void MY_ADC_INT_configvoidPIE_registerPieIntHandlermyPie,PIE_GroupNumber_10,PIE_SubGroupNumber_1,intVec_t 模块中断配置 ADC_setIntPulseGenModemyAdc, ADC_IntPulseGenMode_Prior; ADC_setIntSrcmyAdc,ADC_IntNumber_1, ADC_IntSrc_EOC0; ADC_setIntModemyAdc, ADC_IntNumber_1, ADC_IntMode_ClearFlag; ADC中断使能 ADC_enableIntmyAdc,ADC_IntNumber_1; PIE开关的允许 PIE_enableIntmyPie, PIE_GroupNumber_10, PIE_InterruptSource_ADCINT_10_1; CPU全局中断 CPU_enableIntmyCpu,CPU_IntNumber_10; end of file/*MY_ADC.h*/ifndef _MY_ADC_H_define _MY_ADC_H_ the includesinclude stdint.h driverinclude F2802x_Component/F2802x_Device.hinclude User_Component/User_Mcu/User_System.hifdef cplusplusextern C endififndef TARGET_GLOBAL define TARGET_EXT externelse define TARGET_EXTendif/*- hardware description of the example module -*/TARGET_EXT void MY_ADC_initialvoid;TARGET_EXT void MY_ADC_configvoid;TARGET_EXT void MY_ADC_INT_configvoid;TARGET_EXT interrupt void MY_ADC_isrvoid; redefined in Isr.h/*-end of hardware description -*/TARGET_EXT uint16_t MY_ADC;TARGET_EXT uint16_t SET_TEMP;/*- end of globals -*/ifdef cplusplusendif extern Cendif end of _EXAMPLE_H_ definition/*MY_CAP.c*/ the includesinclude User_Component/MY_CAP/MY_CAP.hinclude User_Component/User_Mcu/User_System.h void MY_CAP_initialvoidvoid MY_CAP_configvoidGPIO_setPullUpmyGpio, GPIO_Number_5, GPIO_PullUp_Enable;GPIO_setQualificationmyGpio, GPIO_Number_5, GPIO_Qual_Sync; GPIO_setModemyGpio, GPIO_Number_5, GPIO_5_Mode_ECAP1; CLK_enableEcap1ClockmyClk; CAP_disableIntmyCap, CAP_Int_Type_All; 禁止CAP中断 CAP_clearIntmyCap, CAP_Int_Type_All; 清除CAP中断标志位 CAP_disableCaptureLoadmyCap; Disable CAP1-CAP4 register loads CAP_disableTimestampCountermyCap; Make sure the counter is stopped Configure peripheral registers CAP_setCapContinuousmyCap; continuous CAP_setStopWrapmyCap, CAP_Stop_Wrap_CEVT4; Stop at 3 events CAP_setCapEvtPolaritymyCap, CAP_Event_1, CAP_Polarity_Rising; 捕获上升沿 CAP_setCapEvtPolaritymyCap, CAP_Event_2, CAP_Polarity_Falling; 捕获下降沿 CAP_setCapEvtPolaritymyCap, CAP_Event_3, CAP_Polarity_Rising; 捕获上升沿 CAP_setCapEvtResetmyCap, CAP_Event_3, CAP_Reset_Enable; 重置计数器确保计数器不会溢出 CAP_enableTimestampCountermyCap; 打开计数器 CAP_enableCaptureLoadmyCap; Enable CAP1-CAP4 register loads /* CAP_enableIntmyCap, CAP_Int_Type_CEVT3; 3个捕获点之后发生中断 Register interrupt handlers in the PIE vector table PIE_registerPieIntHandlermyPie, PIE_GroupNumber_4, PIE_SubGroupNumber_1, intVec_t Enable CPU INT4 which is connected to ECAP1-4 INTCPU_enableIntmyCpu, CPU_IntNumber_4; Enable eCAP INTn in the PIE Group 3 interrupt 1-6 PIE_enableCaptureIntmyPie; CPU_enableGlobalIntsmyCpu; */void MY_CAP_INT_configvoid CAP_enableIntmyCap, CAP_Int_Type_CEVT3; 3 events interrupt Register interrupt handlers in the PIE vector table PIE_registerPieIntHandlermyPie, PIE_GroupNumber_4, PIE_SubGroupNumber_1, intVec_t Enable CPU INT4 which is connected to ECAP1-4 INTCPU_enableIntmyCpu, CPU_IntNumber_4; Enable eCAP INTn in the PIE Group 3 interrupt 1-6 PIE_enableCaptureIntmyPie; CPU_enableGlobalIntsmyCpu; end of file/*MY_CAP.h*/ifndef _MY_CAP_H_define _MY_CAP_H_ the includesinclude stdint.h driverinclude F2802x_Component/F2802x_Device.hifdef cplusplusextern C endififndef TARGET_GLOBAL define TARGET_EXT externelse define TARGET_EXTendif/*- hardware description of the example module -*/TARGET_EXT void MY

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值