SSP work like SPI

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SSP work like SPI

326 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tecnoemerson on Fri Jun 15 18:09:36 MST 2012
I have board where LPC2368 use SSP0 to set DAC MCP4922 by SPI.

I have tried setup SSP to work like SPI, but i didn't have success, below is part of code, please check if is is ok.


static int fnInitMCP4922(void)
{

        POWER_UP(PCSSP0);                                                // power up the SSP used

        PINSEL3 |= (PINSEL3_P1_20_SCK0 | PINSEL3_P1_21_SSEL0 | PINSEL3_P1_23_MISO0 | PINSEL3_P1_24_MOSI0); // SSEL, MOSI, MISO and SCK pins enabled - on SSP0

        SSP0CR0 = 0;       // ensure disabled (master mode)
        SSP0CPSR = 2;      // set clock prescaler (even prescale 2..254)

        SSP0CR0 = (FRS_FREESCALE_SPI | DSS_8_BIT | ((((SSP_CLOCK/2 + 2000000/2)/2000000) - 1) << SSP_SCR_SHIFT)); // set 2MHz and mode
        SSP0CR1 = SSP_SSE;          // enable

_WRITE_PORT(0,  ~PORT0_BIT4); //LOW P0.4 - cs line active low
        WriteSpiData(0xFF);  
        WriteSpiData(0xFF);  
_WRITE_PORT(0, 0XFF); //UP P0.4 - cs line                                         

}

static void WriteSpiData(unsigned int data)
{

    while ((SSP0SR & SSP_TFE) == 0) {                                    // wait for the transfer to complete
    }
    SSP0DR = data;

}



Thanks
Emerson
0 Kudos
1 Reply

265 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Fri Jun 15 22:03:20 MST 2012

Quote: tecnoemerson
I have board where LPC2368 use SSP0 to set DAC MCP4922 by SPI.

I have tried setup SSP to work like SPI, but i didn't have success, below is part of code, please check if is is ok.



1) which lpc1xxx are you using - it might help to tell us instead of letting me guess this is an lpc1754

2) what is "didn't have success" ? Did you see anything on the pins? Did you try to connect an oscilloscope or a logic analyzer ?

3) Have you tried debugging/single stepping and verified the content of the device registers? (during debugging there is a "peripherals"  tab in the left pane where you can examine all registers.

4) your "SSP0CR0 = ..."  assignment looks strange. Why don't you stick to the standard CMSIS defines that NXP delivers with the IDE (LPC_SSP0->CR0 = ...).

5) your code does not help. Everything that is important to know if you did the correct things is hidden in defines.

6) have you looked at the ssp_spi example in the examples.lpc17xx.new.zip example project archive? That contains an example of how to use the SSP as SPI.

Rob
0 Kudos