lpc4357 SPI

ChibiOS public support forum for topics related to the NXP LPC family of Cortex-M micro-controllers.

Moderator: theShed

gvandenbosch
Posts: 21
Joined: Sat Nov 22, 2014 8:23 pm

lpc4357 SPI

Postby gvandenbosch » Sat Nov 22, 2014 8:33 pm

Hello,

I am having a weird issue with the SPI bus on LPC4357, with a logic analyzer the SSEL line gets pulled down and data is seen on the MOSI however there is no clock signal on SCK.
I have tried SSP0 and SSP1 but both have the same issue and I can't figure out why.

Currently is setup to SSP1 with following pin configuration (board.c):

Code: Select all

LPC_SCU->SFSPF_4 = (1<<4) | 0x00;  // SCK FUNC 0 pull inactive
LPC_SCU->SFSPF_5 = 0x02; //SSEL FUNC 2 pull up
LPC_SCU->SFSPF_6 = (1 << 6) | (1<<4) | 0x02; // MISO FUNC 2 pull inactive
LPC_SCU->SFSPF_7 = (1<<4) | 0x02; // MOSI FUNC 2 pull inactive


I have set my spi bus up like:

Code: Select all

const SPIConfig spi1_config = {
    NULL,
    7,
    19,
    CR0_DSS8BIT | CR0_FRFSPI | CR0_CPOL | CR0_CPHA,
    1000000
  } ;


And try to write to SPIbus as following:

Code: Select all

spiAcquireBus(&SPID2);
spiStart(&SPID2,&spi1_config);
chThdSleepMilliseconds(100);
spiSelect (&SPID2);
spiSend (&SPID2, sizeof(uint16_t), &address) ;
spiUnselect (&SPID2);
spiReleaseBus(&SPID2);


In the mcuconf I have enable the SSP and enabled the set SSP clock variable to true, clock source to 0x01 (IRC default).
In halconf.h have set use SPI to true as well.

Can anyone point me in the right direction?

marcinj7
Posts: 13
Joined: Wed Apr 17, 2013 10:08 am
Location: Poland

Re: lpc4357 SPI

Postby marcinj7 » Mon Nov 24, 2014 12:20 am

Hi

Try change last value to 12 or something, this should help.

Code: Select all

const SPIConfig spi1_config = {
    NULL,
    7,
    19,
    CR0_DSS8BIT | CR0_FRFSPI | CR0_CPOL | CR0_CPHA,
    1000000 // <- this value is prescaler, even value between 2 and 254
  } ;

gvandenbosch
Posts: 21
Joined: Sat Nov 22, 2014 8:23 pm

Re: lpc4357 SPI

Postby gvandenbosch » Mon Nov 24, 2014 2:51 pm

Thanks a lot, this was the issue.
I got the example from an other project and they specified the clock in MHz instead of defining the prescaler.


Return to “LPC Support”

Who is online

Users browsing this forum: No registered users and 4 guests