|
|
_& a" P+ ~' L寄存器初始化那里就给出来了啊,如果DSP要发数据给FPGA, 那么CLOCK是由DSP去控制的,如果DSP要接收FPGA的数据,则CLOCK是由FPGA控制的,START跟ENABLE信号是用来控制发送使能的。这是我的初始化配置(我是用8位宽度通信的,对于DSP来说,B是发送,A是接收):
( `8 p/ W- w. S* i9 ostatic void UPPInit(void)+ H" G; F0 r! T" Z7 ^
{; h9 D5 I a$ x) _' {
unsigned int temp_reg = 0;
1 A$ v6 A5 i7 X( z. t/ n3 F) ]8 o3 Z0 [9 \* |$ A8 b
// Channel B params, _% X" f7 { ? `/ J& I4 l8 ]2 w
CSL_FINST(temp_reg, UPP_UPCTL_DPFB, LJZF); //Left-justified, zero filled2 v- J3 z, g" q5 h9 b O: _
CSL_FINST(temp_reg, UPP_UPCTL_IWB, 8BIT); //8-bit interface7 b' M4 B) S# N: O* ?; q
CSL_FINST(temp_reg, UPP_UPCTL_DPWB, FULL); //Channel B bit width = 8! E" ?& c8 U" B" s7 O
CSL_FINST(temp_reg, UPP_UPCTL_DRB, SINGLE); //Single data rate
7 ?( D5 M$ j: I0 K) `
5 [0 W& t H5 t( A8 ~3 ?0 J // Channel A params8 B% Z/ W3 |- q7 V& _! Y, r+ z
CSL_FINST(temp_reg, UPP_UPCTL_DPFA, LJZF); //Left-justified, zero filled" s4 ?( I9 T$ r' ?
CSL_FINST(temp_reg, UPP_UPCTL_IWA, 8BIT); //8-bit interface# }; d' n+ y% Q+ N1 j
CSL_FINST(temp_reg, UPP_UPCTL_DPWA, FULL); //Channel A bit width = 8- _" ^( G! A5 d. H" X' v, z d3 W, J
CSL_FINST(temp_reg, UPP_UPCTL_DRA, SINGLE); //Single data rate
1 ?6 u, \9 S3 ~% `# P7 Z9 z
~+ R6 M0 E" l( ], Q! W CSL_FINST(temp_reg, UPP_UPCTL_CHN, TWO); //Channel A and Channel B are both active.1 X% y/ n6 S5 k; ~- Q
CSL_FINST(temp_reg, UPP_UPCTL_MODE, DUPLEX0); //Channel B transmit Channel A receive, C% d: K+ l; ?/ _
3 K. W/ C' G9 A& O. f
upp_reg_hdl->UPCTL = temp_reg;0 k: f$ h( q4 Y: h# m- t
2 M4 H) \; J$ }$ a temp_reg = 0; 9 h$ w7 y: i3 s" p
. p; A$ |2 {, u! ^5 R
// Channel A params+ n/ \( ]' e2 R. R, e8 v' ]
//CSL_FINST(temp_reg, UPP_UPICR_TRISA, ENABLE); //Channel A data pins are in a high-impedance state while idle
8 r2 |; p; ^1 Y, r0 Z0 W3 h //CSL_FINS(temp_reg, UPP_UPICR_CLKDIVA, UPP_CLOCK_DIV); //Clock divisor
$ ]! ^# ]+ l) l1 O( R6 o CSL_FINST(temp_reg, UPP_UPICR_STARTA, ENABLE); //Channel A START Signal Enable.. c( Z; _% _6 L" m' P; i! }' M' u
CSL_FINST(temp_reg, UPP_UPICR_ENAA, ENABLE); //Channel A ENABLE Signal Enable
/ @* b+ \! t$ u6 i1 e! H$ M7 P2 a7 [! t0 [. {
// Channel B params
% ]$ o9 ]5 ~, J5 k. x; v# E CSL_FINS(temp_reg, UPP_UPICR_CLKDIVB, UPP_CLOCK_DIV);, L `' |0 _; B' Q) j: L
CSL_FINST(temp_reg, UPP_UPICR_STARTB, ENABLE); //Channel B START Signal Enable.) y" y# N+ e6 g3 c0 a+ N- s
CSL_FINST(temp_reg, UPP_UPICR_ENAB, ENABLE); //Channel B ENABLE Signal Enable
( H# |3 |/ o. t4 b
" i! Q9 c5 W! f" J# a- d8 `& D upp_reg_hdl->UPICR = temp_reg;+ T; I, ^: r# O2 \3 S7 g3 L
8 S2 H: A" U/ U //temp_reg = 0;
( S, s+ i" X- F+ _
, ?% \: s# k, z& O //CSL_FINS(temp_reg, UPP_UPIVR_VALB, 0x7b7b); //Channel B idle value
+ U' z- s# O: x7 i6 h //CSL_FINS(temp_reg, UPP_UPIVR_VALA, 0x7f7f); //Channel A idle value
- q" X: x0 U8 C( ]! I) S
. x0 D T' S4 A- c* I //upp_reg_hdl->UPIVR = temp_reg; v) O" a+ S; m1 f
/ _5 |- ?8 ~! j4 h2 V' w //temp_reg = 0;5 ?' A6 m5 l7 J0 w ^0 L
8 {# p" K2 z9 Y Z //CSL_FINST(temp_reg, UPP_UPTCR_RDSIZEI, 256B); //set 256B DMA I
) F" k: d$ v5 }7 [$ H# z5 |: R //upp_reg_hdl->UPTCR = temp_reg;
. |" ]9 @$ u3 t# ^
, v7 V. J- T" I. \ v6 m //temp_reg = 0;
! f" W- Q: u, R2 ]3 M //CSL_FINST(temp_reg, UPP_UPDLB_BA, ENABLE); //B to A loopback mode enable
5 f0 m4 @/ S* g! \. L5 D //upp_reg_hdl->UPDLB = temp_reg;
" B9 c$ f( K; ]6 O" l% u4 V: a% s; K " g7 W* y) s1 {0 b$ r
} |
|