This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SPI Code Problem on F28069

Other Parts Discussed in Thread: ADS1298

Hello,

I`ve started to operate F28069(Piccolo) for control ADS1298.

When I tried to operate ADS1298 using F28069 by SPI, I recieved what I had sent to ADS1298 by TX Buffer.

It looked like a loopback mode, so I checked Loopback mode. However, it was loopback disable.

 

I tried changing POL & PHA but it was ineffective.

In my setting, I use RX Interrupt to recieve data, and just send data to TX Buffer.

I think I rule the MCU to obey Clock formation that ADS1298 needed(POL=0, PHA=1).

 

Here is my code that makes the issue.

void main(void)
{
   InitSysCtrl();
   InitSpiaGpio();
   DINT;
   IER = 0x0000;
   IFR = 0x0000;
   InitPieCtrl();
   InitPieVectTable();
   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.SPIRXINTA = &spiRxFifoIsr;
   PieVectTable.SPITXINTA = &spiTxIsr;
   EDIS;   // This is needed to disable write to EALLOW protected registers

   // ADS1298 POR setting is Omitted

   spi_xmit(0x11);
   DELAY_US(100);
 
 for(a=0;a<28;a++)// OP Code test Form
 {
 spi_xmit(0xF6);
 DELAY_US(100);

 }        
     
         
   for(;;)
   {
    
   }   

}  

void spi_xmit(Uint16 a)
{
    SpiaRegs.SPITXBUF=a;   // I`m not sure it would be a<<8; or not

}   

void spi_fifo_init()
{

//POL=0, PHA=0

// Initialize SPI FIFO registers
   SpiaRegs.SPICCR.bit.SPISWRESET=0; // Reset SPI

   SpiaRegs.SPICCR.all=0x0007;       //8-bit character, POL=0
   SpiaRegs.SPICTL.all=0x0017;       //Interrupt enabled, Master/Slave XMIT enabled, Phase Normal
   SpiaRegs.SPISTS.all=0x0000;
   SpiaRegs.SPIBRR=0x007F;           // Baud rate
   SpiaRegs.SPIFFTX.all=0xC002;      // Enable FIFO's, Disable TXFIFO int
   SpiaRegs.SPIFFRX.all=0x0022;      // Set RX FIFO level to 4
   SpiaRegs.SPIFFCT.all=0x00;
   SpiaRegs.SPIPRI.all=0x0010;

   SpiaRegs.SPICCR.bit.SPISWRESET=1;  // Enable SPI

   SpiaRegs.SPIFFTX.bit.TXFIFO=1;
   SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;
}


interrupt void spiTxIsr(void)
{
 /**/
}

interrupt void spiRxFifoIsr(void)
{
   
    rdata[i%length]=SpiaRegs.SPIRXBUF;     // Read data
   
    i++;   
   
    SpiaRegs.SPIFFRX.bit.RXFFOVFCLR=1;  // Clear Overflow flag
    SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1;  // Clear Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ack
}

 

 

Thank you,

 

Kim 

  • Hi Kim,

    It does not appear you are actually calling your SPI initalization function from main().  Can you verify you reach this function?  Thanks,

    Kris

  • Hello Kris,

     You are right, but... I omitted that.

    I declared spi_fifo_init(); on the main function

    preomitted....

       EALLOW;  // This is needed to write to EALLOW protected registers
       PieVectTable.SPIRXINTA = &spiRxFifoIsr;
       PieVectTable.SPITXINTA = &spiTxIsr;
       EDIS;   // This is needed to disable write to EALLOW protected registers


       spi_fifo_init();   // Initialize the Spi FIFO


       PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
       PieCtrlRegs.PIEIER6.bit.INTx1=1;     // Enable PIE Group 6, INT 1
       PieCtrlRegs.PIEIER6.bit.INTx2=1;     // Enable PIE Group 6, INT 2
       IER=0x20;                            // Enable CPU INT6
       EINT; 

    the rest omitted....

     

    Thanks your point that.

    Could you give me more advices?

     

    Kim.