⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eprom中的监控程序.asm

📁 基于数字信号处理器(DSP)的异步电机直接转矩控制研究(硕士论文),含VC源代码
💻 ASM
📖 第 1 页 / 共 2 页
字号:
*[说明]:此监控程序对应6M晶振,写入80ns的EPROM中,工作正常.
*Register definition
;Interrupt control Module
IFR .set 0006h
IMR .set 0004h
GREG .set 0005h
;System configuration Register
SYSCR .set 7018h
SYSSR .set 701ah
SYSIVR .set 701eh
;Watchdog and Real_Time_Interrupt module
RTICNTR .set 7021h
WDCNTR .set 7023h
WDKEY .set 7025h
RTICR .set 7027h
WDCR .set 7029h
;Clk Module
CKCR0 .set 702bh
CKCR1 .set 702dh
;ADC-A/D Converter module register
ADCTRL1 .set 7032h
ADCTRL2 .set 7034h
ADCFIFO1 .set 7036h
ADCFIFO2 .set 7038h
;Sync port Module
SPICCR .set 7040h
SPICTL .set 7041h
SPISTS .set 7042h
SPIBRR .set 7044h
SPIEMU .set 7046h
SPIBUF .set 7047h
SPIDAT .set 7049h
SPIPC1 .set 704dh
SPIPC2 .set 704eh
SPIPRI .set 704fh
;Serial communications Interface(SCI) module
SCICCR .set 7050h
SCICTL1 .set 7051h
SCIHBAUD .set 7052h
SCILBAUD .set 7053h
SCICTL2 .set 7054h
SCIRXST .set 7055h
SCIRXEMU .set 7056h
SCIRXBUF .set 7057h
SCITXBUF .set 7059h
SCIPC2 .set 705eh
SCIPRI .set 705fh
;external int control register
XINTA1 .set 7070h
XINTA_NMI .set 7072h
XINTB1 .set 7074h
XINTB2 .set 7076h
XINTC1 .set 7078h
XINTC2 .set 707ah
PMINT1 .set 707ch
PMINT2 .set 707eh
;General timer register
GPTCON .set 7400h
T1CNT .set 7401h
T1CMPR .set 7402h
T1PR .set 7403h
T1CON .set 7404h
T2CNT .set 7405h
T2CMPR .set 7406h
T2PR .set 7407h
T2CON .set 7408h
T3CNT .set 7409h
T3CMPR .set 740ah
T3PR .set 740bh
T3CON .set 740ch
;Full and simple compare unit
COMCON .set 7411h
ACTR .set 7413h
SACTR .set 7414h
DBTCON .set 7415h
CMPR1 .set 7417h
CMPR2 .set 7418h
CMPR3 .set 7419h
SCMPR1 .set 741ah
SCMPR2 .set 741bh
SCMPR3 .set 741ch
;Capture and QEP circuit
CAPCON .set 7420h
CAPFIFO .set 7422h
CAP1FIFO .set 7423h
CAP2FIFO .set 7424h
CAP3FIFO .set 7425h
CAP4FIFO .set 7426h
;Event Manager Interrupt register
EVIMRA .set 742ch
EVIMRB .set 742dh
EVIMRC .set 742eh
EVIFRA .set 742fh
EVIFRB .set 7430h
EVIFRC .set 7431h
EVIVRA .set 7432h
EVIVRB .set 7433h
EVIVRC .set 7434h
;User defined Register
***********************************************************************
*外部RAM的8000H-801FH划给监控程序使用,从9000H开始的控制程序不得占用!
***********************************************************************
flag  .set 801fh

count .set 8000h

temp0 .set 8001h
temp1 .set 8002h
temp2 .set 8003h
temp3 .set 8004h
temp4 .set 8005h
temp5 .set 8006h
temp6 .set 8007h
temp7 .set 8008h
temp8 .set 8009h
;Define ext_int location
ext_int1 .set 9002h
ext_int2 .set 9004h
ext_int3 .set 9006h
ext_int4 .set 9008h
ext_int5 .set 900ah
ext_int6 .set 900ch


*Define Interrupt table
 .sect "vectors"
 b start
 b int1
 b int2
 b int3
 b int4
 b int5
 b int6
 .space 45*16
 .word 1,2,3,4,5

  .text 
start: setc INTM; Disable all Interrupt
       clrc SXM
       clrc OVM
       clrc CNF; config block B0(0100--02ffh) to data memory
       mar *,ar7
       lar ar7,#7029h
       splk #006fh,*
       lar ar7,#7025h
       splk #5555h,*
       splk #0aaaah,* ;close watchdog
       ldp #0e0h
       splk #00d0h,CKCR1 ;set CKCR1,Oscilator's frenquency is 6M
       splk #0041h,CKCR0 ;set CKCR0,let Fsysclk=3M
;Set SCI Registers
       splk #0017h,SCICCR ;set SCICCR
       splk #0013h,SCICTL1 ;set SCICTL1
;bit1=1,firstly disable RXRDY/BRKDT interrupt. bit0=0,disable TXRDY interrupt.
       splk #0000h,SCICTL2 ;set SCICTL2
;BRR=0026h=38,actual baud rate is 9615.3.
       splk #0000h,SCIHBAUD ;set SCIHBAUD
       splk #0026h,SCILBAUD ;set SCILBAUD
;bit5=1,bit1=1,pin SCITXD,SCIRXD are used by SCI.
       splk #0022h,SCIPC2 ;set SCIPC2
;write 1 to SCICTL1.5,relinquish SCI from reset.
       splk #0033h,SCICTL1 ;set SCICTL1
       splk #0000h,XINTA1 ;disable XINT1 pin interrupt,interrupt pority:from high to low,
;                          Priority:low(int6)
       splk #0000h,XINTC1
       splk #0000h,XINTC2
         
********************************************************************
*在循环中读进给定量.顺序:CMPR_1,CMPR_2,CMPR_3,T_preiod,dead_time(8021h--8025h)
********************************************************************
;      ldp #0e0h
;first_data:
;       bit SCIRXST,9            
;       bcnd first_data,NTC
;       clrc XF
;       lacl SCIRXBUF ;reading SCIRXBUF can clear flag bit!!
;       sub #50h
;       bcnd receive_error,NEQ ;the first data should be 50H
;second_data:
;       bit SCIRXST,9
;       bcnd second_data,NTC
;       setc XF
;       lacl SCIRXBUF
;       sub #0a0h
;       bcnd receive_error,NEQ ;the second data is a0h
;third_data:
;       bit SCIRXST,9
;       bcnd third_data,NTC
;       clrc XF 
;       lacl SCIRXBUF
;       sub #08h
;       bcnd receive_error,NEQ  ;发送参数的指令码是08H
;fourth_data:
;       bit SCIRXST,9
;       bcnd fourth_data,NTC
;       setc XF
;       lacl SCIRXBUF
;       ldp #100h
;       sacl count ;第四字节是参数个数,保存于count单元
;       mar *,ar7
;       lar ar7,#8021h
;continue:
;       ldp #0e0h        
;receive_geidin:       
;       bit SCIRXST,9  
;       bcnd receive_geidin,NTC 
;       lacl SCIRXBUF
;       sacl * ;先保存参数的高八位
;wait:
;       bit SCIRXST,9
;       bcnd wait,NTC
;       lacc SCIRXBUF
;       add *,8
;       sacl *+ ;这样保存的是16位的参数
;       ldp #100h 
;       lacl count
;       sub #01h
;       sacl count 
;       bcnd  continue,NEQ      

;       ldp #100h
;       lacl CMPR_1
;       ldp #0e8h
;       sacl CMPR1
;       ldp #100h
;       lacl CMPR_2
;       ldp #0e8h
;       sacl CMPR2
;       ldp #100h
;       lacl CMPR_3
;       ldp #0e8h
;       sacl CMPR3
***************************************
*PWM_produce
***************************************
;       ldp #100h
;       lacl dead_time ;(8025h)
;       ldp #0e8h
;       sacl DBTCON 
;       ldp #100h
;       lacl ACTR_gd
;       ldp #0e8h
;       sacl ACTR 
;       splk #4a07h,COMCON
;       splk #0ca07h,COMCON ;ACTR reload--at once,CMPRx reload--at once
*****************************************************
*Initialize GP timer 1
*****************************************************
;       ldp #0e8h
;       splk #0000h,T1CNT
;       ldp #100h
;       lacl T_period
;       ldp #0e8h
;       sacl T1PR ;this is also PWM_period
;       splk #0a840h,T1CON ;continous add/sub mode


*****************************************************
       ldp #0e0h
       splk #0002h,SCICTL2 ;allow RXRDY interrupt
*****************************************************

       ldp #0h
       lacc IFR
       sacl IFR 
       ldp #0h
       splk #0001h,IMR 

;       ldp #0e8h
;       splk #0000h,EVIMRA
        
       ldp #100h
       lacc #0000h
       sacl flag 
       clrc INTM 
main:  nop
       nop
       b main       


;receive_error: 
;              setc XF
;              b main

int1: 
      ldp #100h
      bit flag,14
      bcnd ext_int1,TC ;FLAG[1]=1,转外部INT1
      ldp #0e0h
      lacl SYSIVR 
      sub #0006h
      bcnd receive_error1,NEQ

*注意:进入MAIN_TREAT后,头两个字节为50H和a0H,随后是数据包的长度(如03指令,
*长度为7;15指令,长度为2),然后是指令码(一个字节),然后是起始地址(两个字节)....
*MAIN_TREAT是按上面的规定写的. 有可能要调整.
       clrc SXM ; 进入int1,先抑制符号位扩展
       setc INTM  ;forbid all interrupt
       ldp #0e0h
       splk #0000h,SCICTL2 ;forbid SCI receive interrupt
;      ldp #0h
;      lacl IFR
;      sacl IFR  ; 最好能加上这三句,清除标志位,否则一开总中断马上又进入int1
       ldp #0e0h
first_char:
       bit SCIRXST,9            

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -