DSPRelated.com
Forums

Re: sport test code

Started by zhang zhisheng October 24, 2004
Tim:
now,i just want to send a data by sport0.Please help me check the code followed:
configure the interrupt:
 dis int;
        irptl = 0x0000;  //clear all interrupts
        icntl = 0x0000;  //disable nesting
        imask = 0x0000;  //mask off all interrupts
 
        iopg = Interrupt_Controller_Page;           //0x01
        ar = 0xb1bb;     
        io(IPR0) = ar;
        ar = 0xbbbb;   
        io(IPR2) = ar;
        ar = 0xbbbb;   
        io(IPR1) = ar;
        ar = 0x0bbb;
        io(IPR3) ar;
        ena int;
configure sport0:
 iopg = SPORT0_Controller_Page;  //0x02             
        ar = 0x07E2;           
        io(SP0_TCR) = ar;                                                        
       /* --- HCLK = 80 Mhz. --- */
         ar = 0x0027;            //hclk/(2x(TSCKDIV+1)) = 1mhz.
         io(SP0_TSCKDIV) = ar;
        ar = 0x000F;            //count TFSDIV+1 tclks (16 dec.) for tfs.
        io(SP0_TFSDIV) = ar;
send the data:
iopg = SPORT0_Controller_Page;
 
   ar = io(SP0_TCR);
   ar = setbit 0 of ar;
        io(SP0_TCR) = ar;  //Turn on sport0 transmitter
        ar = 0xff;
  io(SP0_TX) = ar;  
 
  Sport0 TX Interrupt Service Routine:
IVS0TX: ay1 = iopg;
             iopg = SPORT0_Controller_Page;
             ar = io(SP0_TCR);
             ar = clrbit 0 of ar;
             io(SP0_TCR) = ar;  //Turn off sport0 transmitter  
  
             iopg = General_Purpose_IO;
             ar = 0xff;
             io(FLAGC) = ar;
             ar = 0x0008;
             io(FLAGS) ar;
             iopg = ay1;
             irptl = 0x0000;