📄 lf_pwm.lst
字号:
00016 ;/*
00017 ;
00018 ; This macro initialises the SPI module
00019 ;
00020 ;*/
00021 SPI.Init macro
00022 banksel TRISC
00023 movlw b'11001110' ; Set LFDATA,ALERT, and CS as inputs
00024 movwf TRISC ;
00025 banksel PORTC
00026 bsf AFECS ; Take AFE CS Line high
00027 endm
00028
00029
00030
00031
00032 ;
00033 ; This macro shifts data out of the MCU through the SPI-Interface.
00034 ;
00035 ;
00036 ; @param SPI.BufferH The most significant Byte of the Data
00037 ; @param SPI.BufferL The least significant Byte of the Data
00038 ;
00039 ; @example
00040 ; pagesel SPI.BufferH
00041 ; movlw 0xf0
00042 ; movwf SPI.BufferH
00043 ; movlw 0x0f
00044 ; movwf SPI.BufferL
00045 ; call SPI.Write
00046 ; @end-ex
00047 ; @ex-desc This sends 0xf00f over the SPI-Bus
00048 ;
00049 ; @status Written
00050 ;
00051 ; @stacklevel +1
00052 ;
00053 ;
00054 ;
00055 ;SPI.Write macro
00056 ; call SPI.ShiftOutBuffer
MPASM 5.14 LF_PWM.ASM 9-26-2008 8:07:54 PAGE 6
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00057 ; endm
00058
00059
00060
00061 ;
00062 ; This macro reads two Bytes from the SPI-Bus.
00063 ; Put the Read command and the address in the SPI.BufferH and SPI.BufferL Registers.
00064 ; Then call SPI.Read.
00065 ; Then read the returned values in SPI.BufferH and SPI.BufferL.
00066 ;
00067 ;
00068 ; @param SPI.BufferH The most significant Byte of the Data
00069 ; @param SPI.BufferL The least significant Byte of the Data
00070 ;
00071 ;
00072 ; @return SPI.BufferH The most significant Byte of the Data
00073 ; @return SPI.BufferL The least significant Byte of the Data
00074 ;
00075 ; @example
00076 ; pagesel SPI.BufferH
00077 ; movlw 0xf0
00078 ; movwf SPI.BufferH
00079 ; movlw 0x0f
00080 ; movwf SPI.BufferL
00081 ; call SPI.Read
00082 ; @end-ex
00083 ; @ex-desc This sends 0xf00f over the SPI-Bus, and reads the answer to SPI.BufferH and SPI.BufferL
.
00084 ;
00085 ; @status Written
00086 ;
00087 ; @stacklevel +1
00088 ;
00089 ;
00090 ;
00091 ;SPI.Read macro
00092 ; call SPI.ShiftOutBuffer
00093 ; call SPI.ShiftInBuffer
00094 ; endm
00095
00096
00097 endif
00029 #include AFE_639.inc
00001 #ifndef AFE_639_INC
00002 #define AFE_639_INC
00003
00004
00005
00006 #include SPI.inc
00098 ifndef SPI_INC
00099 #define SPI_INC
00100
00101 ;/*
MPASM 5.14 LF_PWM.ASM 9-26-2008 8:07:54 PAGE 7
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00102 ; Stores the most significant Byte
00103 ;*/
00104 extern SPI.BufferH
00105 ;/*
00106 ; Stores the least significant Byte
00107 ;*/
00108 extern SPI.BufferL
00109 extern SPI.Read, SPI.Write
00110 ;extern SPI.ShiftOutBuffer, SPI.ShiftInBuffer
00111
00112
00113 ;/*
00114 ;
00115 ; This macro initialises the SPI module
00116 ;
00117 ;*/
00118 SPI.Init macro
00119 banksel TRISC
00120 movlw b'11001110' ; Set LFDATA,ALERT, and CS as inputs
00121 movwf TRISC ;
00122 banksel PORTC
00123 bsf AFECS ; Take AFE CS Line high
00124 endm
00125
00126
00127
00128
00129 ;
00130 ; This macro shifts data out of the MCU through the SPI-Interface.
00131 ;
00132 ;
00133 ; @param SPI.BufferH The most significant Byte of the Data
00134 ; @param SPI.BufferL The least significant Byte of the Data
00135 ;
00136 ; @example
00137 ; pagesel SPI.BufferH
00138 ; movlw 0xf0
00139 ; movwf SPI.BufferH
00140 ; movlw 0x0f
00141 ; movwf SPI.BufferL
00142 ; call SPI.Write
00143 ; @end-ex
00144 ; @ex-desc This sends 0xf00f over the SPI-Bus
00145 ;
00146 ; @status Written
00147 ;
00148 ; @stacklevel +1
00149 ;
00150 ;
00151 ;
00152 ;SPI.Write macro
00153 ; call SPI.ShiftOutBuffer
00154 ; endm
MPASM 5.14 LF_PWM.ASM 9-26-2008 8:07:54 PAGE 8
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00155
00156
00157
00158 ;
00159 ; This macro reads two Bytes from the SPI-Bus.
00160 ; Put the Read command and the address in the SPI.BufferH and SPI.BufferL Registers.
00161 ; Then call SPI.Read.
00162 ; Then read the returned values in SPI.BufferH and SPI.BufferL.
00163 ;
00164 ;
00165 ; @param SPI.BufferH The most significant Byte of the Data
00166 ; @param SPI.BufferL The least significant Byte of the Data
00167 ;
00168 ;
00169 ; @return SPI.BufferH The most significant Byte of the Data
00170 ; @return SPI.BufferL The least significant Byte of the Data
00171 ;
00172 ; @example
00173 ; pagesel SPI.BufferH
00174 ; movlw 0xf0
00175 ; movwf SPI.BufferH
00176 ; movlw 0x0f
00177 ; movwf SPI.BufferL
00178 ; call SPI.Read
00179 ; @end-ex
00180 ; @ex-desc This sends 0xf00f over the SPI-Bus, and reads the answer to SPI.BufferH and SPI.BufferL
.
00181 ;
00182 ; @status Written
00183 ;
00184 ; @stacklevel +1
00185 ;
00186 ;
00187 ;
00188 ;SPI.Read macro
00189 ; call SPI.ShiftOutBuffer
00190 ; call SPI.ShiftInBuffer
00191 ; endm
00192
00193
00194 endif
00007
00008
00009 ;/*
00010 ; The RAM-Map of the AFE's configuration register (8 byte)
00011 ;*/
0000 00012 extern AFE.ConfMap
0000 00013 extern AFE.Buffer
0000 00014 extern AFE.LoadCfg, AFE.SafeCfg, AFE.ReadCfg, AFE.WriteCfg, AFE.WriteRegister, AFE.ReadRegister,
AFE.WriteNVerifyRegister
0000 00015 extern AFE.CalcColumnParity
00016
00017
MPASM 5.14 LF_PWM.ASM 9-26-2008 8:07:54 PAGE 9
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00018 #define AFE.Alert PORTC,2 ; SPI Clock Output
00019
00020 #define AFE.CMDClampOn B'00000000'
00021 #define AFE.CMDClampOff B'00100000'
00022 #define AFE.CMDSleep B'01000000'
00023 #define AFE.CMDAGCOn B'01100000'
00024 #define AFE.CMDAGCOff B'10000000'
00025 #define AFE.CMDSR B'10100000'
00026
00027 #define AFE.ModDepth12 B'00110000'
00028 #define AFE.ModDepth25 B'00100000'
00029 #define AFE.ModDepth75 B'00010000'
00030 #define AFE.ModDepth50 B'00000000'
00031
00032
00033 ;/*
00034 ;
00035 ; This macro initialises the AFE
00036 ;
00037 ;*/
00038 AFE.Init macro
00039 call AFE.LoadCfg
00040 call AFE.WriteCfg
00041 ; call AFE.ReadCfg
00042 AFE.SendCMDSoftReset
00043 banksel PORTA ;just debugging
00044 btfss AFE.Alert
00045 goto $-1
00046 endm
00047
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -