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

📄 sendword.s

📁 dsPIC对于交流感应电机矢量控制的应用笔记的源代码(中文)
💻 S
字号:
;*******************************************************************
; Routines: SendWord
;
;*******************************************************************

; Common to all routines in file

          .include "general.inc"

          .extern _SendWord

;*******************************************************************
; SendWord
;  
;Description:        
;
;Functional prototype:
; 
; void SendWord( short S, short Shiftleft, short Sync )
;
;*******************************************************************
;
;=================== CODE =====================
          .section  .text

          .global   _SendWord

_SendWord:
          btsc      U1STAbits,#UTXBF    ; buffer full
          bra       _SendWord

          sl        w0,w1,w0            ; shift w0 left by w1

     ;; w0 = 15b 14b 13b 12b 11b 10b 9b 8b 7b 6b 5b 4b 3b 2b 1b 0b 
          lsr       w0,w0               ; shift w0  right by 1

     ;; 0 15b 14b 13b 12b 11b 10b 9b 8b 7b 6b 5b 4b 3b 2b 1b 

          btsc      w2,#0
          bset      w0,#15

     ;; w0 = f 15b 14b 13b 12b 11b 10b 9b 8b 7b 6b 5b 4b 3b 2b 1b 
     ;; where f = Sync &1

     ;; split into two bytes with flag in upper bit of each

          lsr       w0,#8,w1            ; shift w0 right by 8 into w1

     ;; w1 = 0 0 0 0 0 0 0 0 f 15b 14b 13b 12b 11b 10b 9b

          mov       w1,_U1TXREG
          
jSendWord1:
          btsc      U1STAbits,#UTXBF    ; buffer full
          bra       jSendWord1

     ;; w0 = f 15b 14b 13b 12b 11b 10b 9b 8b 7b 6b 5b 4b 3b 2b 1b 

          lsr       w0,w1               ; shift w0 right by 1 into w1

     ;; w1 = 0 f 15b 14b 13b 12b 11b 10b 9b 8b 7b 6b 5b 4b 3b 2b

          and       #0x007F,w1

     ;; lower byte = 0 8b 7b 6b 5b 4b 3b 2b

          mov       w1,_U1TXREG

          return

          .end

⌨️ 快捷键说明

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