AnsweredAssumed Answered

Programming SPI1 of BF592

Question asked by Nikos1984 on Oct 6, 2011
Latest reply on Oct 6, 2011 by Prashant

Dear Sir or Madam,

 

I am programming SPI1 of BF592, in order to interface it with an ADC. I have no error in my code. However I cannot see any of the SPI1 in my scope.

I cannot see any reason for not been activated, unless the interrupt priority for SPI1 is wrong. This is how I am setting up SPI1:

 

 

void init_port()

 

{
    *pPORTG_MUX = 0;

 


    *pPORTG_FER = 0xffff;

 

}

void init_SPI()

 

{
     *pSPI1_FLG = FLS5;    // Set baud rate SCK = HCLK/(2*SPIBAUD) SCK = 2MHz   
    *pSPI1_BAUD = 100;    // configure spi port
    // SPI DMA write, 16-bit data, MSB first, SPI Master
    *pSPI1_CTL = 0x0000 | SIZE | MSTR;   

 

}

 

void init_interrupts()

 

{
    int i;
   *pSIC_IAR2 = 0xff0fffff;        //Setup different priorities for UART transmit and receive

 

    register_handler(ik_ivg10, SPI_receive_ISR);
   
    *pSIC_IMASK0 |= 0x00200000;   
    i = *pSPI1_RDBR;
   
}

 

void enable_Rx_DMA()

 

{
// enable DMAs

 

*pDMA6_CONFIG = (*pDMA6_CONFIG | DMAEN);    // enable spi
    *pSPI1_CTL = (*pSPI1_CTL | SPE);
   
}

 

void init_ADC()
{
    int j;

 

    // Enable PF4
   
    *pSPI1_FLG = FLS5;                  // Set baud rate SCK = HCLK/(2*SPIBAUD) SCK = 2MHz   
    *pSPI1_BAUD = 100;                  // configure spi port
    // SPI DMA write, 16-bit data, MSB first, SPI Master
    *pSPI1_CTL = 0x0001 | SIZE | MSTR ;  

 


    *pDMA6_CONFIG = WDSIZE_16;

 

 
    *pDMA6_START_ADDR = (void *)ADC_CONFIG_WORD;

 

    *pDMA6_X_COUNT = 1;

    *pDMA6_X_MODIFY = 2;

   
     *pDMA6_CONFIG = (*pDMA6_CONFIG | DMAEN);  

 

    // enable spi
    *pSPI1_CTL = (*pSPI1_CTL | SPE);
    
    *pSPI1_TDBR = ADC_CONFIG_WORD;            

 

    for (j=0; j<0xffff; j++)
        asm("nop;");   

 

    *pSPI1_CTL&= 0x3fff;
}

 

 

 

 

Thank you in advance.

 

Kind Regards,

Nikos Zafeiropoulos

Outcomes