TMS320VC5402與單片機(jī)的HPI口通信設(shè)計(jì)
MOV R2 , # 00H ;寫幀類型
MOV R3 , # 02H
LCALL LWHPID
MOV R2 , # 00H ;寫DA TA[0 ]
MOV R3 , # 03H
LCALL LWHPID
MOV IE , # 81H ;主機(jī)中斷允許
MOV R2 , # 04H ;DSP HPI 中斷
MOV R3 , # 04H
LCALL WHPIC ;寫HPIC
SJMP $ ;等待主機(jī)中斷發(fā)生
typedef st ruct
{ int head ; / 3 f ramehead 3 /
int length ; / 3 f ramelength 3 /
int f unc ; / 3 f unc type 3 /
int data [ 253 ] ; / 3 t he data 3 /
} HPIFRAME ;
HPIFRAME hpiinbuf ;
HPIFRAME hpiout buf ;
# pragma DA TA_SECTION (hpiinbuf ,
" . hpibuffer" )
# pragma DA TA_SECTION (hpioutbuf ,
" . hpibuffer" )
void main ()
{ char hpidatacnt ;
HPIFRAME 3 hpiinbufpt r = hpiinbuf ;
HPIFRAME 3 hpiout bufpt r = hpiout buf ;
c54_init () ;
ser0inwrcnt = 1 ;
ser0out rdcnt = 5 ;
ser0inrdcnt = 5 ;
ser0outwrcnt = 1 ;
ser0flag = 0 ;
for ( ; ;) {
if (hpirecflag > = 1) {
hpirecflag = 0 ;
if (hpiinbufpt r - > head = = 0xaa) {
hpiout bufpt r - > head = 0xaa00 + hpiinbufpt r
- > lengt h ;
hpiout bufpt r - > f unc = hpiinbufpt r - > f unc ;
for (hpidatacnt = 0 ;hpidatacnt hpiinbufpt r
- > lengt h ;hpidatacnt + + )
hpiout bufpt r - > data[ hpidatacnt ] =
hpiinbufpt r - > data[ hpidatacnt ] ;
hpidsp_host () ; } } } }
圖2 主機(jī)編程流程圖
3 結(jié)束語(yǔ)
DSP 與單片機(jī)的混合系統(tǒng)設(shè)計(jì),可實(shí)現(xiàn)雙方優(yōu)勢(shì)互補(bǔ),在信號(hào)處理及控制顯示電路設(shè)計(jì)中是一款較佳的設(shè)計(jì)方案.
評(píng)論