AnsweredAssumed Answered

SPORT interrupt

Question asked by tec on Sep 25, 2009
Latest reply on Sep 30, 2009 by DeepV

Hello,

 

I want to transmit one 16 bit DMA message using the SPORT0. I cannot get the message to stop transmitting out of the DSP. I read that the *pCSP0A count should self decrement after each sent message. I have my *pCSP0A set to 1 as you can see in my code below. Why do I get DMA sport messages continuously? I inserted a SPORT interrupt in my code so I can do somethings after my 16 bit message goes out. I read that the interrupt will be called after the transmit buffer is empty. Below is my code.

 

void configure_SPORT_for_PRF()
{
// we need a code data and clock line
    // Configure SPORT as a transmitter
   unsigned int buffer5 = 0x11111711;

    // reset the PRF direction back to command the missile from the DSP
    // the acceptance pulse code might have changed the direction earlier
    SRU( LOW, DAI_PB01_I); // set the direction of the line level shifter from right to left

// Connect the SPORT clocks to the clock pin
    SRU(SPORT0_CLK_O, DAI_PB10_I); // pin 12
    SRU( HIGH, PBEN10_I); // enable the clock line as output
   
    SRU(SPORT0_DA_O, DAI_PB06_I); //  Connect the pin buffers to the SPORT data lines and DAI07 pin 8
    SRU( HIGH, PBEN06_I); // enable the data line as output

    // also routing it directly back to
// SPORTx_CLK_I to give the state machine its signal
   //SRU(SPORT0_CLK_O, SPORT0_CLK_I);
interrupt (SIG_SP0, PRF_transmit_interrupt ); // this will stop the SPORT

    //printf("0x%x\n", PRF );
//*pIISP0A = (unsigned int) &PRF;  // start address of data buffer
*pIISP0A = &buffer5;  // start address of data buffer
*pIMSP0A = 1; // address increment
*pCSP0A = 1; // number of words to transmit

    // the CLKDIV is placed in the 2nd bit of the DIVx so shift by 1 bit
*pDIV0 = 49200; // 2Hz
 
    // turn on the least significant bit format as found in A-32 of the hardware manual
    //initially clear SPORT control register
    *pSPMCTL0 = 0 ;
    *pSPCTL0 = 0 ;
    //*pSPCTL0 |= 0x8;
  
// use standard DSP serial mode
// The SPORTs are ready to start transmitting or receiving data two serial clock
// cycles after they are enabled in the SPCTLx registers.   
*pSPCTL0 |= (SPEN_A|    /* Enable Channel A */
         SLEN32|    /* 16-bit word length */
         SPTRAN|    /* Transmit on enabled channels */
         SDEN_A|    // Enable Channel A DMA
         //CKRE |
         //LSBF|
         //FSR| // try
         IFS| // try
         ICLK ); // use an internal clock for the clock output
}

 

void PRF_transmit_interrupt( int sig ) // 17
{   
//SRU( HIGH, DAI_PB01_I); // set the 74LVX4245 direction bit to receive 5 volts and convert it to 3.3
return;

    // I will receive this DMA interrupt after the PRF is done transmitting
// this interrupt will tell me to look for the acceptance pulse
*pSPMCTL0 = 0;
*pSPCTL0 = 0; // turn off the SPORT

SRU( LOW, PBEN06_I); // set the serial line to be input to read an acceptance pulse

// tell the interrupt that the acceptance pulse will be on the PRF line
//SRU(DAI_PB06_O, MISCA2_I); // the misc 2 line is set up to get an interrupt from a rising edge

// set the timer
// the PRF acceptance pulse will arrive around 3 msec after the 16th bit. It will last around 5msec
// start a timer so I know to only wait for the acceptance pulse for 6 msec
    /* Using PWM Out mode as a core timer */
    * (volatile int *) TM2CTL = TIMODEPWM|     /* PWM Out Mode */
                                PRDCNT|        /* Count to end of period */
                                IRQEN;

    // set the timer to go off every 500 Hz
    * (volatile int *) TM2PRD = MAX_ACCEPTANCE_COUNTS; // Timer 2 period
    * (volatile int *) TM2W = 1;                        /* Timer 2 Pulse width = 1 */
    * (volatile int *) TMSTAT |= TIM2EN;                 /* enable timer 2 */
   
interrupt(SIG_GPTMR2, acceptance_timer_isr);

//SRU(HIGH,DAI_PB16_I); // set the acceptance view bit high so we can see that it is working

// if this was a R09 message then I need to send one more clock pulse
// to tell the missile that the data is done transmitting
if( sending_R09 == 1 )
{
  sending_R09 = 0;
  // set the PBEN10_I high for 1/10K clock pulses
  SRU( HIGH, DAI_PB10_I ); // raise the line high
  Delay( (unsigned int)(CLOCK_TICS_PER_SEC*0.0001) ); // hold the line high for about .1 msecs
  SRU( LOW,  DAI_PB10_I ); // set it back low again
 
  printf("R09done\n" );
}
else
   printf("PRFdone\n" );
}

Outcomes