SSP not working (not signals out) SOLVED

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

SSP not working (not signals out) SOLVED

1,026 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Sun May 03 17:18:18 MST 2015
Hi

I've been struggling with the SSP block since few weeks. In order to keep my project moving on I implemented bit-banging SPI. But I need the SPI working for this and any other project that needs that interface.

I've tried some diferents codes, but none has given results. I'm pretty shure I'm missing something trivial, but I can't see what it is. The next code is the last I've tried:

void Delay(uint32_t ticks)
{
volatile uint32_t i;

for (; ticks > 0; --ticks) {
for (i = 1000; i > 0; --i) {
__NOP();
}
}
}

int main(void) 
{
SSP_InitTypeDef spi;
SSP_StructInit(&spi);
SSP_Init(&spi);
// spi estándar config

SSP_SetClockRate(1000000);
// clock rate a 1MHz

IOCON_PIO_CFG_Type io;
IOCON_StructInit(&io);
io.type = IOCON_PIO_0_14; IOCON_SetFunc(&io);
//sck

io.type = IOCON_PIO_0_17; IOCON_SetFunc(&io);
// mosi

SSP_Cmd(ENABLE); // (1)

while (1)
{
SSP_SendData(0xaa);
//while (SSP_GetStatus(SSP_STATUS_TFE) == RESET) ;
                // I've commented this line in order no to mess right now with those flags
                // Anyway they are not helping at all

Delay(100);
                // I guess this is enough time for a byte to go out
                // Board is running at 12MHz
}
    return 0 ;
}


After the line marked with (1) is passed these are the values taken for the most important registers in the SSP block:

CR0 = 0xB07
CR1 = 0x2
SR = 0x3
CPSR = 0x2

All of them seems to be Ok, but I get nothing in the output (SCK and MOSI). I remember an errata from the elder LPC2129 in which the SSEL pin must be configured as part of the SPI (in oposition of letting it as gpio in master mode). Would be the same case?

In order to be easier to read the dozens bits while configuring the SSP block I took some notes and those are attached.

Any help or idea is welcomed. Thank you!
Labels (1)
0 Kudos
2 Replies

825 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Mon May 04 23:15:53 MST 2015
What a silly mistake!  :bigsmile:

Thank you wmues! You're right, I wasn't configuring the pins as SPI but as GPIOs. I knew I wasn't overlooking something, thanks for pointing it out. Next is the correct code:

int main(void) 
{
SSP_InitTypeDef spi;
SSP_StructInit(&spi);
SSP_Init(&spi);
// spi estándar config

SSP_SetClockRate(1000000);
// clock rate a 1MHz

IOCON_PIO_CFG_Type io;
IOCON_StructInit(&io);
io.type = IOCON_SSP_SCK; IOCON_SetFunc(&io);
//sck

io.type = IOCON_SSP_MOSI; IOCON_SetFunc(&io);
// mosi

SSP_Cmd(ENABLE);

while (1)
{
SSP_SendData(0xaa);
//while (SSP_GetStatus(SSP_STATUS_TFE) == RESET) ;
Delay(100);
}
    return 0 ;
}
0 Kudos

825 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Mon May 04 07:33:14 MST 2015
You are missing the setup of the pins in SSP mode.

Look here
0 Kudos