LPC54110 板子 SDK2.0 freertos_spi 运行

NXP 官网 提供的SDK2.0 是基于 lpcxpresso54114 板子的

连接方法为:

Board settings
==============
Populate jumper JP6.
Connect SPI5 pins to SPI3 pins:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Master - SPI5                 CONNECTS TO      Slave - SPI3
Pin Name   Board Location                      Pin Name  Board Location
MISO       J1 pin 11                           MISO      J4 pin 3
MOSI       J1 pin 13                           MOSI      J4 pin 2
SCK        J2 pin 8                            SCK       J4 pin 4
PCS2       J1 pin 15                           PCS2      J4 pin 7
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

对应的LPC54110 板子上面的管脚:

pin namepinpin namepin
MISOP0.18MISOP0.13
MOSIP0.20MOSIP0.12
SCKP0.19SCKP0.11
PCS2P1.1PCS2P0.4

log为:

FreeRTOS SPI example start.
This example use one SPI instance as master and another as slave on one board.
Master and slave are both use interrupt way.
Please make sure you make the correct郌reeRTOS SPI example start.
This example use one SPI instance as master and another as slave on one board.
Master and slave are both use interrupt way.
Please make sure you make the correct line connection. Basically, the connection is: 
 SPI_master -- SPI_slave   
   SCK      --    SCK  
   PCS2     --    PCS2 
   MISO     --    MISO  
   MOSI      --   MOSI 
Master transmited:
0x 0  0x 1  0x 2  0x 3  0x 4  0x 5  0x 6  0x 7  
0x 8  0x 9  0x a  0x b  0x c  0x d  0x e  0x f  
0x10  0x11  0x12  0x13  0x14  0x15  0x16  0x17  
0x18  0x19  0x1a  0x1b  0x1c  0x1d  0x1e  0x1f  

Slave received:
0x 0  0x 1  0x 2  0x 3  0x 4  0x 5  0x 6  0x 7  
0x 8  0x 9  0x a  0x b  0x c  0x d  0x e  0x f  
0x10  0x11  0x12  0x13  0x14  0x15  0x16  0x17  
0x18  0x19  0x1a  0x1b  0x1c  0x1d  0x1e  0x1f  

Slave transmited:
0xff  0xfe  0xfd  0xfc  0xfb  0xfa  0xf9  0xf8  
0xf7  0xf6  0xf5  0xf4  0xf3  0xf2  0xf1  0xf0  
0xef  0xee  0xed  0xec  0xeb  0xea  0xe9  0xe8  
0xe7  0xe6  0xe5  0xe4  0xe3  0xe2  0xe1  0xe0  

Master received:
0xff  0xfe  0xfd  0xfc  0xfb  0xfa  0xf9  0xf8  
0xf7  0xf6  0xf5  0xf4  0xf3  0xf2  0xf1  0xf0  
0xef  0xee  0xed  0xec  0xeb  0xea  0xe9  0xe8  
0xe7  0xe6  0xe5  0xe4  0xe3  0xe2  0xe1  0xe0  

SPI master transfer completed successfully.
Slave-to-master data verified ok.
SPI slave transfer completed successfully. 
Master-to-slave data verified ok.

连接方法:
这里写图片描述

原始状态:
这里写图片描述

SW3 — PO_4

I2C P025 P026 怎么修改为 P023 P024
LD7 —- LED4 —— P0_25
LD6 —- LED5 ——- P0_26

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我知道了。关于你的第一个问题,以下是基于LPC5516的spi_dma_b2b例程修改后的8路SPI同时通过DMA0传输数据的C语言程序: ```c #include "board.h" #include "periph_spi_dma.h" #define BUFFER_SIZE 32 /* SPI master select, to select slave to communicate */ #define LPC_SLAVE_A_SPI_PORT 0 #define LPC_SLAVE_A_SPI_PIN 15 #define LPC_SLAVE_B_SPI_PORT 0 #define LPC_SLAVE_B_SPI_PIN 16 #define LPC_SLAVE_C_SPI_PORT 0 #define LPC_SLAVE_C_SPI_PIN 17 #define LPC_SLAVE_D_SPI_PORT 0 #define LPC_SLAVE_D_SPI_PIN 18 #define LPC_SLAVE_E_SPI_PORT 0 #define LPC_SLAVE_E_SPI_PIN 19 #define LPC_SLAVE_F_SPI_PORT 0 #define LPC_SLAVE_F_SPI_PIN 20 #define LPC_SLAVE_G_SPI_PORT 0 #define LPC_SLAVE_G_SPI_PIN 21 #define LPC_SLAVE_H_SPI_PORT 0 #define LPC_SLAVE_H_SPI_PIN 22 /* SPI master and slave configuration */ static SPI_CONFIG_T mstCfg0 = { SPI_MODE_MASTER, /* Transfer mode */ 0, /* Bus configuration: ignored in master mode */ SPI_CLOCK_CPHA0_CPOL0, /* Clock mode */ SPI_DATA_MSB_FIRST, /* Data order: MSB first */ SPI_SSEL_ACTIVE_LO, /* Slave select is active low */ 8 /* SPI clock divider - not used in master mode */ }; static SPI_DMA_CONFIG_T dmaCfg = { SPI_DMA_CHAN_TX_RX, /* DMA configuration */ SPI_DMA_INT_EN, /* DMA interrupt enable */ SPI_DMA_INTSTAT_TXERR, /* DMA interrupt status */ BUFFER_SIZE /* DMA transfer size */ }; static SPI_DMA_HANDLE_T spiHandle; /* Sample data buffer */ static uint32_t txBuf[ BUFFER_SIZE ]; static uint32_t rxBuf[ BUFFER_SIZE ]; static uint32_t rxSlaveABuf[ BUFFER_SIZE ]; static uint32_t rxSlaveBBuf[ BUFFER_SIZE ]; static uint32_t rxSlaveCBuf[ BUFFER_SIZE ]; static uint32_t rxSlaveDBuf[ BUFFER_SIZE ]; static uint32_t rxSlaveEBuf[ BUFFER_SIZE ]; static uint32_t rxSlaveFBuf[ BUFFER_SIZE ]; static uint32_t rxSlaveGBuf[ BUFFER_SIZE ]; static uint32_t rxSlaveHBuf[ BUFFER_SIZE ]; /* Function prototypes */ static void initSpiMaster( void ); static void initSpiSlave( uint8_t port, uint8_t pin ); int main(void) { /* Initialize board */ Board_Init(); /* Initialize master and slaves */ initSpiMaster(); initSpiSlave( LPC_SLAVE_A_SPI_PORT, LPC_SLAVE_A_SPI_PIN ); initSpiSlave( LPC_SLAVE_B_SPI_PORT, LPC_SLAVE_B_SPI_PIN ); initSpiSlave( LPC_SLAVE_C_SPI_PORT, LPC_SLAVE_C_SPI_PIN ); initSpiSlave( LPC_SLAVE_D_SPI_PORT, LPC_SLAVE_D_SPI_PIN ); initSpiSlave( LPC_SLAVE_E_SPI_PORT, LPC_SLAVE_E_SPI_PIN ); initSpiSlave( LPC_SLAVE_F_SPI_PORT, LPC_SLAVE_F_SPI_PIN ); initSpiSlave( LPC_SLAVE_G_SPI_PORT, LPC_SLAVE_G_SPI_PIN ); initSpiSlave( LPC_SLAVE_H_SPI_PORT, LPC_SLAVE_H_SPI_PIN ); /* Start SPI transfers */ SPI_DMA_TRANSFER_T transfer; transfer.pTxData = txBuf; transfer.pRxData[0] = rxBuf; transfer.pRxData[1] = rxSlaveABuf; transfer.pRxData[2] = rxSlaveBBuf; transfer.pRxData[3] = rxSlaveCBuf; transfer.pRxData[4] = rxSlaveDBuf; transfer.pRxData[5] = rxSlaveEBuf; transfer.pRxData[6] = rxSlaveFBuf; transfer.pRxData[7] = rxSlaveGBuf; transfer.pRxData[8] = rxSlaveHBuf; transfer.dataLength = BUFFER_SIZE; SPI_DmaTransfer( &spiHandle, &dmaCfg, &transfer ); while (1) {} } static void initSpiMaster( void ) { /* Initialize SPI0 as master with SSEL0 */ Chip_SPI_Init( LPC_SPI0 ); Chip_SPI_ConfigureSPI( LPC_SPI0, &mstCfg0 ); Chip_Clock_EnablePeriphClock( SYSCTL_CLOCK_SPI0 ); Chip_SPI_Enable( LPC_SPI0 ); /* Set SPI 0.15 as GPIO output */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LPC_SLAVE_A_SPI_PORT, LPC_SLAVE_A_SPI_PIN); /* Set SPI 0.16 as GPIO output */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LPC_SLAVE_B_SPI_PORT, LPC_SLAVE_B_SPI_PIN); /* Set SPI 0.17 as GPIO output */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LPC_SLAVE_C_SPI_PORT, LPC_SLAVE_C_SPI_PIN); /* Set SPI 0.18 as GPIO output */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LPC_SLAVE_D_SPI_PORT, LPC_SLAVE_D_SPI_PIN); /* Set SPI 0.19 as GPIO output */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LPC_SLAVE_E_SPI_PORT, LPC_SLAVE_E_SPI_PIN); /* Set SPI 0.20 as GPIO output */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LPC_SLAVE_F_SPI_PORT, LPC_SLAVE_F_SPI_PIN); /* Set SPI 0.21 as GPIO output */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LPC_SLAVE_G_SPI_PORT, LPC_SLAVE_G_SPI_PIN); /* Set SPI 0.22 as GPIO output */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, LPC_SLAVE_H_SPI_PORT, LPC_SLAVE_H_SPI_PIN); } static void initSpiSlave( uint8_t port, uint8_t pin ) { /* Set SPI slave select as GPIO output */ Chip_GPIO_SetPinDIROutput(LPC_GPIO, port, pin); /* Set SPI slave select high to de-select slave */ Chip_GPIO_SetPinState(LPC_GPIO, port, pin, true); } ``` 请注意,以上程序仅供参考,请根据实际要求进行修改和调试。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值