?? ad9852.asm
字號:
//函數(shù):_main
//功能:
//參數(shù):
.include hardware.inc
.ram
.var lxp_Delay_t;
.var FreqH; //頻率控制字
.var FreqM;
.var FreqL;
.var ControlH; //控制寄存器控制字
.var ControlL;
.var AMPL; //幅度控制字
.var Shape; //輸出斜率控制字
.code
.public _main
_main:
init:
r1 = 0x0000;
[FreqH] = r1;
r1 = 0x0000;
[FreqM] = r1;
r1 = 0x0000;
[FreqL] = r1;
r1 = 0x1464;
[ControlH] = r1;
r1 = 0x8070;
[ControlL] = r1;
r1 = 0x0f00;
[AMPL] = r1;
r1 = 0xff00;
[Shape] = r1;
irq off;
r1 =0x000f; //IOB0為CS;IOB1為CLK;IOB2為SDIO;IOB3為UDC;
[P_IOB_Dir] = r1;
[P_IOB_Attrib] = r1;
r1 = 0x0000;
[P_IOB_Data] = r1;
r1 = 0x0002;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r2 = [FreqH];
r1 = r2;
r1 = r1 lsr 4;
r1 = r1 lsr 4;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = r2;
r1 &= 0x00ff;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r2 = [FreqM];
r1 = r2;
r1 = r1 lsr 4;
r1 = r1 lsr 4;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = r2;
r1 &= 0x00ff;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r2 = [FreqL];
r1 = r2;
r1 = r1 lsr 4;
r1 = r1 lsr 4;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = r2;
r1 &= 0x00ff;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = 0x0007;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r2 = [ControlH];
r1 = r2;
r1 = r1 lsr 4;
r1 = r1 lsr 4;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = r2;
r1 &= 0x00ff;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r2 = [ControlL];
r1 = r2;
r1 = r1 lsr 4;
r1 = r1 lsr 4;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = r2;
r1 &= 0x00ff;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = 0x0008;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r2 = [AMPL];
r1 = r2;
r1 = r1 lsr 4;
r1 = r1 lsr 4;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = r2;
r1 &= 0x00ff;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = 0x000a;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = [Shape];
r1 = r1 lsr 4;
r1 = r1 lsr 4;
push r1 to [sp];
call _lxp_SPI_Write;
pop r1 from [sp];
r1 = [P_IOB_Data];
r1 |= 0x0008;
[P_IOB_Data] = r1;
r1 = [P_IOB_Data];
r1 |= 0x0001;
[P_IOB_Data] = r1;
//函數(shù):_lxp_ShortDelay()
//功能:短延時
//說明:延時(lxp_Delay_t*2+2)個機(jī)器周期
.public _lxp_ShortDelay
_lxp_ShortDelay: .proc
push r1 to [sp];
r1 = [lxp_Delay_t];
loop:
r1 -= 1;
jnz loop;
r1=0x0001;
[P_Watchdog_Clear]=r1; //清看門狗
pop r1 from [sp];
retf
.endp
//函數(shù):_lxp_LongDelay()
//功能:長延時
//說明:延時(lxp_Delay_t*2*6+8)個機(jī)器周期
.public _lxp_LongDelay
_lxp_LongDelay: .proc
push r1,r2 to [sp];
r1 = [lxp_Delay_t];
r2 = r1;
r1 = r1 lsl 2;
r1 += r2; //r1 *= 6;
r1 += r2; //
loop1:
r2=0x0001; //清看門狗
[P_Watchdog_Clear]=r2;
r1 -= 1;
jnz loop1;
pop r1,r2 from [sp];
retf
.endp
//函數(shù):_lxp_SPI_Write()
//功能:向SPI 總線寫入1 個字節(jié)的數(shù)據(jù)
//參數(shù):dat:要寫入的數(shù)據(jù)
.public _lxp_SPI_Write
_lxp_SPI_Write: .proc
push r1,r5 to [sp];
irq off;
r1 = [P_IOB_Dir];
r1 |= 0x0007;
r1 &= 0xfff7;
[P_IOB_Dir] = r1;
[P_IOB_Attrib] = r1;
bp = sp + 8; //bp指向參數(shù)
r4 = [bp]; //參數(shù)放入r4
r3 = 8; //向SPI 總線寫入八位數(shù)二進(jìn)制數(shù)
loopx:
test r4,0x80;
jz DIO_0_1; //dat7為低,制DIO為0
jmp DIO_1_1; //dat7為高,制DIO為1
DIO_0_1:
r1 = [P_IOB_Data]; //lxp_pin_DIO = 0;
r1 &= 0xfffb; //1&x = x;0&x = 0; 1111111111111011
[P_IOB_Data] = r1;
jmp zbt_1;
DIO_1_1:
r1 = [P_IOB_Data]; //lxp_pin_DIO = 1;
r1 |= 0x0004; //0|x = x;1|x = 1; 0000000000000100
[P_IOB_Data] = r1;
zbt_1:
r4 = r4 lsl 1; //dat<<=1;
r1 = [P_IOB_Data];
r1 |= 0x0002;
[P_IOB_Data] = r1; //lxp_pin_CLK = 1;
call _lxp_ShortDelay;
r1 = [P_IOB_Data];
r1 &= 0xfffd;
[P_IOB_Data] = r1; //lxp_pin_CLK = 0;
call _lxp_ShortDelay;
r3 -= 1;
jnz loopx;
irq on;
pop r1,r5 from [sp];
retf
.endp
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -