LPCXpresso LPC54618 mcu SPI

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

LPCXpresso LPC54618 mcu SPI

550 Views
shaheenshamshad
Contributor III

I have imported "Spi_interrupt_b2b_transfer_master" example from LPCxpresso sdk 2.3.1 example.

It was for SPI9 so I changed it to SPI1 as per my need. Even changed the pin in pinmux.c file as below:

const uint32_t port1_pin9_config = (/* Pin is configured as FC9_SCK */
IOCON_PIO_FUNC1 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT3 PIN20 (coords: N2) is configured as FC9_SCK */
IOCON_PinMuxSet(IOCON, 1U, 9U, port1_pin9_config);

const uint32_t port2_pin3_config = (/* Pin is configured as FC9_RXD_SDA_MOSI */
IOCON_PIO_FUNC1 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT3 PIN21 (coords: P5) is configured as FC9_RXD_SDA_MOSI */
IOCON_PinMuxSet(IOCON, 2U, 3U, port2_pin3_config);

const uint32_t port2_pin4_config = (/* Pin is configured as FC9_TXD_SCL_MISO */
IOCON_PIO_FUNC1 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT3 PIN22 (coords: N5) is configured as FC9_TXD_SCL_MISO */
IOCON_PinMuxSet(IOCON, 2U, 4U, port2_pin4_config);

const uint32_t port2_pin5_config = (/* Pin is configured as FC9_CTS_SDA_SSEL0 */
IOCON_PIO_FUNC1 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT3 PIN30 (coords: K13) is configured as FC9_CTS_SDA_SSEL0 */
IOCON_PinMuxSet(IOCON, 2U, 5U, port2_pin5_config);

But I am not getting any clock in SPI CLK pin.

Kindly guide.

1 Reply

381 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello! 

The problem is with the functions you are selecting for each pin, you left everything with the Function 1 and this is wrong, since the functions change for each pin. You can refer the user manual of the LPC54618 (UM10912.pdf) in the chapter 10, table 256 you will find a table where you will see all the different functions for each pin. 

For the SCK you are selecting port1_pin9 in function one. In the image below you can see that the correct function is the number 2 in order to be the SCK of the SPI1. pastedImage_1.png

For the MISO (port2_pin4), MOSI (port2_pin3) and SSEL (port2_pin5) you selected function one. However, for these pins the correct function is number 3, as shown below. 

pastedImage_2.png

Your code should look like the following.

const uint32_t port1_pin9_config = (/* Pin is configured as FC9_SCK */
IOCON_PIO_FUNC2 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT3 PIN20 (coords: N2) is configured as FC9_SCK */
IOCON_PinMuxSet(IOCON, 1U, 9U, port1_pin9_config);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

const uint32_t port2_pin3_config = (/* Pin is configured as FC9_RXD_SDA_MOSI */
IOCON_PIO_FUNC3 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT3 PIN21 (coords: P5) is configured as FC9_RXD_SDA_MOSI */
IOCON_PinMuxSet(IOCON, 2U, 3U, port2_pin3_config);

Also keep in mind that the example is using the Flexcomm9 since it's using SPI9. You want to use the SPI1, so, you will need to use the Flexcomm1. 

Hope it helps!

Victor.

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------