📄 mcbsp_spi.asm
字号:
.include "mcbsp_reg.asm"
.def setTo8BitMode_
.def setTo16BitMode_
;.def setTo5_8BitMode_
.def setTo40BitMode_
.def SPIModeInitial ;the default is also 8BitMode
SPIModeInitial:
;reset the mcbsp usin serial port control register2
*port(SPCR1_0)=#1800h;#0210h ;0200
;set the mcbsp value
*port(SPCR2_0)=#0200h;#2010h;80
;pin control register
*port(PCR0)=#0a0dh ;active high, 3 is thoery value.
*port(RCR1_0)=#0000h ;receive frame don't ignal, and delay=1 bit
*port(RCR2_0)=#0001h
*port(XCR2_0)=#0001h;;change here
*port(XCR1_0)=#0000h ;change here for the frame length and word length
;set the mcbsp clk freqency in sample rate generater 2
*port(SRGR2_0)=#2008h;#3028h;
*port(SRGR1_0)=#0009h ;change the frequency here to /9+1
repeat(#10)
nop_16
;de-reset the serial port control register2 by 3 steps
;1: sample rate generate
;2: dx and dr
;3: frame syc.
*port(SPCR2_0)=#0240h;#0250h
repeat(#20)
nop_16
*port(SPCR2_0)=#0241h
*port(SPCR1_0)=#1801h;old value is 0080 disable or 0081 enable
*port(SPCR2_0)=#02c1h
repeat(#80)
nop_16
return
setTo8BitMode_2:
;reset the mcbsp usin serial port control register2
*port(SPCR1_0)=#1800h;#0210h ;0200
;set the mcbsp value
*port(SPCR2_0)=#0200h;#2010h;80
;pin control register
*port(PCR0)=#0a0dh ;active high, 3 is thoery value.
*port(RCR1_0)=#0000h ;receive frame don't ignal, and delay=1 bit
*port(RCR2_0)=#0001h
*port(XCR2_0)=#0001h;;change here
*port(XCR1_0)=#0000h ;change here for the frame length and word length
;set the mcbsp clk freqency in sample rate generater 2
*port(SRGR2_0)=#2008h;#3028h;
*port(SRGR1_0)=#0009h ;change the frequency here to /9+1
repeat(#10)
nop_16
;de-reset the serial port control register2 by 3 steps
;1: sample rate generate
;2: dx and dr
;3: frame syc.
*port(SPCR2_0)=#0240h;#0250h
repeat(#20)
nop_16
*port(SPCR2_0)=#0241h
*port(SPCR1_0)=#1801h;old value is 0080 disable or 0081 enable
*port(SPCR2_0)=#02c1h
repeat(#80)
nop_16
return
setTo16BitMode_2:
;reset the mcbsp usin serial port control register2
*port(SPCR1_0)=#1800h;#0210h ;0200
;set the mcbsp value
*port(SPCR2_0)=#0200h;#2010h;80
;pin control register
*port(PCR0)=#0a0dh ;active high, 3 is thoery value.
*port(RCR1_0)=#0040h ;receive frame don't ignal, and delay=1 bit
*port(RCR2_0)=#0001h
*port(XCR2_0)=#0001h;;change here
*port(XCR1_0)=#0040h ;change here for the frame length and word length
;set the mcbsp clk freqency in sample rate generater 2
*port(SRGR2_0)=#2010h;#3028h;
*port(SRGR1_0)=#0009h ;change the frequency here to /9+1
repeat(#10)
nop_16
;de-reset the serial port control register2 by 3 steps
;1: sample rate generate
;2: dx and dr
;3: frame syc.
*port(SPCR2_0)=#0240h;#0250h
repeat(#20)
nop_16
*port(SPCR2_0)=#0241h
*port(SPCR1_0)=#1801h;old value is 0080 disable or 0081 enable
*port(SPCR2_0)=#02c1h
repeat(#80)
nop_16
return
setTo16BitMode_:
;reset the mcbsp usin serial port control register2
*port(SPCR1_0)=#1800h;#0210h ;0200
;set the mcbsp value
*port(SPCR2_0)=#0200h;#2010h;80
;pin control register
*port(PCR0)=#0a0dh ;active high, 3 is thoery value.
;*port(RCR1_0)=#0000h ;receive frame don't ignal, and delay=1 bit
*port(RCR2_0)=#0005h
*port(XCR2_0)=#0005h;;change here
;*port(XCR1_0)=#0000h ;change here for the frame length and word length
*port(RCR1_0)=#0040h ;receive frame don't ignal, and delay=1 bit
*port(XCR1_0)=#0040h ;change here for the frame length and word length
;set the mcbsp clk freqency in sample rate generater 2
*port(SRGR2_0)=#2030h;#3028h;
*port(SRGR1_0)=#0009h ;change the frequency here to /9+1
repeat(#10)
nop_16
;de-reset the serial port control register2 by 3 steps
;1: sample rate generate
;2: dx and dr
;3: frame syc.
*port(SPCR2_0)=#0240h;#0250h
repeat(#20)
nop_16
*port(SPCR2_0)=#0241h
*port(SPCR1_0)=#1801h;old value is 0080 disable or 0081 enable
*port(SPCR2_0)=#02c1h
repeat(#80)
nop_16
return
;set the mcbsp value
;*port(SPCR2_0)=#02c0h;#2010h;80
;*port(SPCR1_0)=#1800h
;set the mcbsp clk freqency in sample rate generater 2
;set the mcbsp clk freqency in sample rate generater 2
;*port(SPCR2_0)=#02c1h
;*port(SPCR1_0)=#1800h
setTo8BitMode_:
;reset the mcbsp usin serial port control register2
;*port(SPCR1_0)=#1800h;#0210h ;0200
;set the mcbsp value
;*port(SPCR2_0)=#0200h;#2010h;80
*port(RCR1_0)=#0000h ;receive frame don't ignal, and delay=1 bit
*port(XCR1_0)=#0000h ;change here for the frame length and word length
;set the mcbsp clk freqency in sample rate generater 2
*port(SRGR2_0)=#2008h;#3028h;
;*port(SPCR1_0)=#1801h;old value is 0080 disable or 0081 enable
;*port(SPCR2_0)=#02c1h
return
setTo40BitMode_:
;reset the mcbsp usin serial port control register2
*port(SPCR1_0)=#1800h;#0210h ;0200
;set the mcbsp value
*port(SPCR2_0)=#0200h;#2010h;80
;pin control register
*port(PCR0)=#0a0dh ;active high, 3 is thoery value.
;*port(RCR1_0)=#0000h ;receive frame don't ignal, and delay=1 bit
*port(RCR2_0)=#0005h
*port(XCR2_0)=#0005h;;change here
;*port(XCR1_0)=#0000h ;change here for the frame length and word length
*port(RCR1_0)=#0240h ;receive frame don't ignal, and delay=1 bit
*port(XCR1_0)=#0240h ;change here for the frame length and word length
;set the mcbsp clk freqency in sample rate generater 2
*port(SRGR2_0)=#202ah;#3028h;
*port(SRGR1_0)=#0009h ;change the frequency here to /9+1
repeat(#10)
nop_16
;de-reset the serial port control register2 by 3 steps
;1: sample rate generate
;2: dx and dr
;3: frame syc.
*port(SPCR2_0)=#0240h;#0250h
repeat(#20)
nop_16
*port(SPCR2_0)=#0241h
*port(SPCR1_0)=#1801h;old value is 0080 disable or 0081 enable
*port(SPCR2_0)=#02c1h
repeat(#80)
nop_16
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -