LPC55S69 SPI通信

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

LPC55S69 SPI通信

Jump to solution
790 Views
wangyibin
Contributor II

我在SDK生成的样码lpcxpresso55s69_spi_interrupt_b2b_transfer_master中没有找到把片选信号拉低的代码。在程序的readme.txt中把P17 pin1作为片选信号, 我用示波器测量片选信号,只有在调用SPI_MasterTransferNonBlocking(EXAMPLE_SPI_MASTER, &handle, &xfer)发送和接受数据的时候片选被拉低。

在main函数的文件中有#define EXAMPLE_SPI_SSEL 1 ,我感觉他是片选信号,但把他改为0,测量P17 pin1的值无变化。

最后我们这个SDK的SPI例程在与其它板子的芯片进行SPI通信时,需要改什么配置吗?还是说直接修改发送的buff就行?

wangyibin_0-1645583210444.png

 

0 Kudos
1 Solution
784 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

This is the SPI initialization code

The spi_ssel_t is defined in the fsl_spi.h file.

typedef enum _spi_ssel
{
kSPI_Ssel0 = 0, /*!< Slave select 0 */
kSPI_Ssel1 = 1, /*!< Slave select 1 */
kSPI_Ssel2 = 2, /*!< Slave select 2 */
kSPI_Ssel3 = 3, /*!< Slave select 3 */
} spi_ssel_t;

 

 

SPI_MasterGetDefaultConfig(&masterConfig);
sourceClock = EXAMPLE_SPI_MASTER_CLK_FREQ;

//if you select the SPI_SSEL0
masterConfig.sselNum = kSPI_Ssel0;

//if you select the SPI_SSEL1
masterConfig.sselNum = kSPI_Ssel1;

//if you select the SPI_SSEL2
masterConfig.sselNum = kSPI_Ssel2;


masterConfig.sselPol = (spi_spol_t)EXAMPLE_SPI_SPOL;
SPI_MasterInit(EXAMPLE_SPI_MASTER, &masterConfig, sourceClock);

 

But you have to configure the SSEL pin so that it is the SPI_SSELx output

For example, you configure the SPI sselx pin

CLOCK_EnableClock(kCLOCK_Iocon);

 

In the pin_mux.c

//P1_20 function as FC7_RTS_SCLX_SSEL1

const uint32_t port1_pin20_config = (/* Pin is configured as FC7_RTS_SCL_SSEL1 */
IOCON_PIO_FUNC1 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT1 PIN20 (coords: 4) is configured as FC7_RTS_SCL_SSEL1 */
IOCON_PinMuxSet(IOCON, 1U, 20U, port1_pin20_config);

 

If you select P1_21 as  FC7_CTS_SDAX_SSEL0

const uint32_t port1_pin21_config = (/* Pin is configured as FC7_RTS_SCL_SSEL1 */
IOCON_PIO_FUNC1 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT1 PIN20 (coords: 4) is configured as FC7_RTS_SCL_SSEL1 */
IOCON_PinMuxSet(IOCON, 1U, 21U, port1_pin21_config);

Pls have a try

 

Hope it can help you

BR

XiangJun Rong

View solution in original post

1 Reply
785 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

This is the SPI initialization code

The spi_ssel_t is defined in the fsl_spi.h file.

typedef enum _spi_ssel
{
kSPI_Ssel0 = 0, /*!< Slave select 0 */
kSPI_Ssel1 = 1, /*!< Slave select 1 */
kSPI_Ssel2 = 2, /*!< Slave select 2 */
kSPI_Ssel3 = 3, /*!< Slave select 3 */
} spi_ssel_t;

 

 

SPI_MasterGetDefaultConfig(&masterConfig);
sourceClock = EXAMPLE_SPI_MASTER_CLK_FREQ;

//if you select the SPI_SSEL0
masterConfig.sselNum = kSPI_Ssel0;

//if you select the SPI_SSEL1
masterConfig.sselNum = kSPI_Ssel1;

//if you select the SPI_SSEL2
masterConfig.sselNum = kSPI_Ssel2;


masterConfig.sselPol = (spi_spol_t)EXAMPLE_SPI_SPOL;
SPI_MasterInit(EXAMPLE_SPI_MASTER, &masterConfig, sourceClock);

 

But you have to configure the SSEL pin so that it is the SPI_SSELx output

For example, you configure the SPI sselx pin

CLOCK_EnableClock(kCLOCK_Iocon);

 

In the pin_mux.c

//P1_20 function as FC7_RTS_SCLX_SSEL1

const uint32_t port1_pin20_config = (/* Pin is configured as FC7_RTS_SCL_SSEL1 */
IOCON_PIO_FUNC1 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT1 PIN20 (coords: 4) is configured as FC7_RTS_SCL_SSEL1 */
IOCON_PinMuxSet(IOCON, 1U, 20U, port1_pin20_config);

 

If you select P1_21 as  FC7_CTS_SDAX_SSEL0

const uint32_t port1_pin21_config = (/* Pin is configured as FC7_RTS_SCL_SSEL1 */
IOCON_PIO_FUNC1 |
/* Selects pull-up function */
IOCON_PIO_MODE_PULLUP |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT1 PIN20 (coords: 4) is configured as FC7_RTS_SCL_SSEL1 */
IOCON_PinMuxSet(IOCON, 1U, 21U, port1_pin21_config);

Pls have a try

 

Hope it can help you

BR

XiangJun Rong