毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 论文 >> 正文

单片机智能遥控器系统设计 第7页

更新时间:2009-6-28:  来源:毕业论文
单片机智能遥控器系统设计 第7页
主程序的逐步设计
3.3.1 程序流程图3.3.2主程序详细编码
//预定义
#define P_IOA_Data          (volatile unsigned int *)0x7000
#define P_IOA_Buffer      (volatile unsigned int *)0x7001
#define P_IOA_Dir       (volatile unsigned int *)0x7002
#define P_IOA_Attrib      (volatile unsigned int *)0x7003
#define P_IOA_Latch         (volatile unsigned int *)0x7004
#define P_IOB_Data      (volatile unsigned int *)0x7005
#define P_IOB_Buffer      (volatile unsigned int *)0x7006
#define P_IOB_Dir       (volatile unsigned int *)0x7007
#define P_IOB_Attrib        (volatile unsigned int *)0x7008
#define P_Watchdog_Clear       (volatile unsigned int *)0x7012
#define P_SystemClock    (volatile unsigned int *)0x7013

#define Key_5    (volatile unsigned int *)0x0008  //5键
#define Key_6    (volatile unsigned int *)0x0004  //6键
#define Key_1    (volatile unsigned int *)0x000c  //1键
#define Key_2    (volatile unsigned int *)0x0002  //2键
#define Key_3    (volatile unsigned int *)0x000a  //3键
#define Key_4    (volatile unsigned int *)0x0006  //4键
#define Key_7    (volatile unsigned int *)0x000e  //7键
#define Key_8    (volatile unsigned int *)0x0001  //8键
#include "hardware.h"
#include "s480.h"
unsigned int KeyFlag=0;    //当前按键的状态,1有效
unsigned int KeyState=0;   //遥控输入
void PlayRespond(int Result)        //发音子函数的定义
www.751com.cn
ACM_S480_Stop
(); 
}
//主程序开始
main()
{
 //初始化;
 InitIOA();                            //初始化A口
 InitIOB();                            //初始化B口
 INT1kHzON();                        //开启1KHz中断
SACM_S480_Initial(1);                //初始化SACM_S480  
 //循环等待按键
 while(1)
 {
  switch(KeyState)
  {
  case Key_5:
    PlayRespond(5);
   break;
  case Key_6:  
    PlayRespond(6);
   break;
  case Key_1:  
    PlayRespond(1);
   break;
  case Key_2:  
    PlayRespond(2);
   break;
  case Key_3:
    PlayRespond(3);
   break;
  case Key_4:  
    PlayRespond(4);
   break;
  case Key_7:
    PlayRespond(7);
   break;
  case Key_8:
    PlayRespond(8);
   break;
  }    
 } 
 INT1kHzOFF();                            //关闭1KHz中断
}
3.5中断服务程序设计
3.5.1中断程序流程
SPACE061A中断源列表
 
3.5.2中断服务程序编码
.INCLUDE  hardware.inc
.INCLUDE  Resource.inc
.include s480.inc

.DEFINE    RUN_1kHz_TimeBase_INT   0x0010  //遥控输入
.EXTERNAL  _GTime
.EXTERNAL  _KeyFlag
.EXTERNAL  _KeyState
.EXTERNAL  R_InterruptStatus

.PUBLIC  _FIQ,_BREAK,_IRQ0, _IRQ1, _IRQ2, _IRQ3, _IRQ4, _IRQ5, _IRQ6, _IRQ7

.code
.PUBLIC _INT1kHzOFF
_INT1kHzOFF:.proc
 int off
    R1 = 0xffff
    [P_INT_Clear] = R1           // Clear interrupt occuiped events
    R1 = [R_InterruptStatus]  //
    R1 &= 0xffef     // Disenable 1kHz IRQ
    [R_InterruptStatus] = R1  //
    [P_INT_Ctrl] = R1    //
 int irq
 retf
.endp

.TEXT
_FIQ:
 PUSH R1,R4 to [sp];
 R1 = 0x0001;
    [P_Watchdog_Clear] = R1;
 R1 = 0x2000;
 test R1,[P_INT_Ctrl];
 jnz L_FIQ_TimerA;
 R1 = 0x0800;
 test R1,[P_INT_Ctrl];
 jnz L_FIQ_TimerB;
L_FIQ_PWM:
 R1 = C_FIQ_PWM;
 [P_INT_Clear] = R1;
 POP R1,R4 from[sp];
 reti;
L_FIQ_TimerA:
 [P_INT_Clear] = R1;
 call F_FIQ_Service_SACM_S480;
 pop R1,R4 from [sp];
 RETI;
L_FIQ_TimerB:
 [P_INT_Clear] = R1;
 pop R1,R4 from [sp];
 RETI;
_BREAK:

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

单片机智能遥控器系统设计 第7页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©751com.cn 辣文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。