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

📄 sub_sine_on_digi_pot.s

📁 该文件包含30F的电机控制程序
💻 S
字号:
;START_HEADER
;
; dsPIC30F6014 Demo Source File
; (c) Copyright 2005 Microchip Technology, All rights reserved
;
; --------------------------------------------------------------------------
; File Revision History:
; --------------------------------------------------------------------------
;
; $Log: sub_sine_on_digi_pot.s,v $
; Revision 1.4  2005/04/04 23:38:21  VasukiH
; Updated comments in header
;
; Revision 1.3  2005/04/04 23:13:47  VasukiH
; Updates for MPLAB C30 v1.30 compatiblity
;
; Revision 1.2  2003/11/04 02:34:20  VasukiH
; changed include file directive
;
; Revision 1.1.1.1  2003/08/23 00:38:33  VasukiH
; First import of demo source into CVS Repository
;
;
;
; --------------------------------------------------------------------------
;
; Software and Development Tools Info:
; --------------------------------------------------------------------------
; Tool                          Version
; --------------------------------------------------------------------------
; MPLAB IDE                     7.0
; MPLAB C30 Toolsuite           1.30
; dsPICDEM(TM) Processor Board  1.10
; --------------------------------------------------------------------------
;
; File Notes:
; 1. The subroutine in this file is called by the timer1 interrupt service
;    routine. Timer1 period-match event occurs every 125 microseconds and
;    this subroutine is called. This subroutine transmits the next sample
;    from a sine table to the Digital Pot using the SPI2 module.
;
;END_HEADER

.include "p30fxxxx.inc"


.global SineTableStep
.global SineTablePtr
.global CurrFreqSel, NewFreqSel
.global _init_SPI2_for_DigiPot


.section .ndata, data, near
SineTableStep:          .hword 10*2
SineTablePtr:           .hword psvoffset(SineTable)
CurrFreqSel:            .hword 0b0000000000000001
NewFreqSel:             .hword 0b0000000000000000



;User code section in Program Memory
.section .text
.global _sub_sine_on_digi_pot
_sub_sine_on_digi_pot:

        push.d  w0
        push.d  w2
        push    CORCON
        push    PSVPAG
        push    SPI2CON
        push    SPI2STAT


        rcall   _init_spi2_B

        mov     #psvpage(SineTable), w0
        mov     w0, PSVPAG
        bset    CORCON, #PSV

        mov     #psvoffset(SineTable)+1600, w0
        cp      SineTablePtr
        bra     lt, LoadNextSample

        sub     SineTablePtr, WREG
        mov     #psvoffset(SineTable), w1
        add     w0, w1, w0
        mov     w0, SineTablePtr

LoadNextSample:
        mov     SineTablePtr, w1
        mov     SineTableStep, w2
        mov     [w1], w0
        add     w1, w2, w1
        bset    w0, #12
        bset    w0, #8
        mov     w1, SineTablePtr
        bclr    PORTD, #RD7
        mov     WREG, SPI2BUF
DigiPotUpdated:
        btss    IFS1, #SPI2IF
        bra     DigiPotUpdated

        mov     SPI2BUF, w0
        bclr    SPI2STAT, #SPIROV


        bclr    IFS1, #SPI2IF
        bset    PORTD, #RD7

        disi    #3
        bset    IEC1, #SPI2IE
        pop     SPI2STAT
        pop     SPI2CON
        pop     PSVPAG
        pop     CORCON
        pop.d   w2
        pop.d   w0

        return





.end                                            ;End of all code in this file

⌨️ 快捷键说明

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