📄 dacs.sdi
字号:
,,,;***************************************************
,,,; DACS.ASM MPB 11-2-06
,,,;
,,,; Test program for parallel
,,,; and serial D/A Converters
,,,; DAC0808 & MCP4921
,,,;
,,,; Proteus simulation DACS.DSN
,,,;
,,,;***************************************************
,,,
,,, PROCESSOR 16F877A
,,, INCLUDE "P16F877A.INC"
00002007,3731,, __CONFIG 0X3731
,,,
,,,Hibyte EQU 020 ; SPI data high byte
,,,Lobyte EQU 021 ; SPI data low byte
,,,
,,, ORG 0 ; Load at default range
00000000,0000,, NOP ; for ICD operations
,,,
,,,; Initialise parallel and serial ports -------------
,,,
00000001,1683 1303,, BANKSEL TRISD
00000003,0188,, CLRF TRISD ; Parallel port
00000004,1287,, BCF TRISC,5 ; Serial data
00000005,1187,, BCF TRISC,3 ; Serial clock
00000006,1007,, BCF TRISC,0 ; Chip select
00000007,0194,, CLRF SSPSTAT ; default SPI mode
,,,
00000008,1283 1303,, BANKSEL PORTD
0000000A,0188,, CLRF PORTD ; zero PDAC
0000000B,0194,, CLRF SSPCON ; default SPI mode
,,,
0000000C,3039,, MOVLW B'00111001' ; Initial SDAC data
0000000D,00A0,, MOVWF Hibyte ; and store
0000000E,30FF,, MOVLW B'11111111'
0000000F,00A1,, MOVWF Lobyte
,,,
,,,; Check buttons ------------------------------------
,,,
00000010,1886,up,up BTFSC PORTB,1 ; Test UP button
00000011,2816,, GOTO down ; and jump if off
00000012,0A88,, INCF PORTD ; Increment PDAC
00000013,0AA0,, INCF Hibyte ; Increment SDAC
00000014,1C86,waitup,waitup BTFSS PORTB,1 ; Wait for..
00000015,2814,, GOTO waitup ; button release
,,,
00000016,1906,down,down BTFSC PORTB,2 ; Test DOWN button
00000017,281C,, GOTO spi ; and jump if off
00000018,0388,, DECF PORTD ; Decrement PDAC
00000019,03A0,, DECF Hibyte ; Decrement SDAC
0000001A,1D06,waitdo,waitdo BTFSS PORTB,2 ; Wait for..
0000001B,281A,, GOTO waitdo ; button release
,,,
,,,; Send 16-bit data to SDAC via SPI port ------------
,,,
0000001C,1694,spi,spi BSF SSPCON,SSPEN ; Enable SPI port
,,,
0000001D,1007,, BCF PORTC,0 ; Enable SDAC chip
0000001E,0820,, MOVF Hibyte,W ; Get high data
0000001F,0093,, MOVWF SSPBUF ; and send it
00000020,1D8C,waithi,waithi BTFSS PIR1,SSPIF ; Wait for..
00000021,2820,, GOTO waithi ; SPI interrupt
00000022,118C,, BCF PIR1,SSPIF ; Reset interrupt
,,,
00000023,0821,, MOVF Lobyte,W ; Get low data
00000024,0093,, MOVWF SSPBUF ; and send it
00000025,1D8C,waitlo,waitlo BTFSS PIR1,SSPIF ; Wait for..
00000026,2825,, GOTO waitlo ; SPI interrupt
00000027,118C,, BCF PIR1,SSPIF ; Reset interrupt
,,,
00000028,1407,, BSF PORTC,0 ; Disable SDAC chip
,,,
,,,; Run output loop until reset ---------------------
,,,
00000029,1806,, BTFSC PORTB,0 ; Test run button
0000002A,2810,, GOTO up ; and repeat loop
,,,
0000002B,0A88,run,run INCF PORTD ; Increment PDAC
0000002C,282B,, GOTO run
,,,
,,, END ;---------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -