Problem with LPC54113 SPI Configuring Using MCUxpresso

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem with LPC54113 SPI Configuring Using MCUxpresso

3,708 次查看
TDC1333
Contributor III

Hello,

I am interfacing LPC54113 with ADS1293 using SPI Protocol.

I have configured Flexcom5 for SPI Using MCUxpresso IDE,But SPI not working.SDI Pin Showing Low voltage.

For Configuration setting PFA>

See Below code,

static void SPI_master_callback(SPI_Type *base,spi_master_handle_t *handle, status_t status,void *userData)
{
isFinished = true;
}

SPI_MasterTransferCreateHandle(ECG_PERIPHERAL, &ECG_handle, SPI_master_callback, NULL); // SPI Handler ECG

///////////////////////////////////////////////////////////////////////////////////////////////////////

void ads1293WriteRegister(uint8_t wrAddress, uint8_t data)
{
uint8_t dataToSend = (wrAddress & WREG);
spi_transfer_t ALL_SPI_Transfer;
memset(&ALL_SPI_Transfer, 0, sizeof(ALL_SPI_Transfer));
//digitalWrite(csPin, LOW);
GPIO_PinWrite(BOARD_INITPINS_ECG_CS_GPIO,BOARD_INITPINS_ECG_CS_PORT,BOARD_INITPINS_ECG_CS_PIN,0U);
ECG_txdbuff[0] = dataToSend;
// ECG_txdbuff[1] = 0x00;
ECG_txdbuff[1] = data;
ALL_SPI_Transfer.txData = ECG_txdbuff;
ALL_SPI_Transfer.rxData = NULL;
ALL_SPI_Transfer.dataSize = sizeof(ECG_txdbuff);
// Send out.
SPI_MasterTransferNonBlocking(ECG_PERIPHERAL, &ECG_handle, &ALL_SPI_Transfer);
while(!isFinished)
{
}
GPIO_PinWrite(BOARD_INITPINS_ECG_CS_GPIO,BOARD_INITPINS_ECG_CS_PORT,BOARD_INITPINS_ECG_CS_PIN,1U);
// digitalWrite(csPin, HIGH);
}

////////////////////////////////////////////////////////////////////////////////////////////////////

uint8_t ads1293ReadRegister(uint8_t rdAddress){

uint8_t rdData;
uint8_t dataToSend = (rdAddress | RREG);
spi_transfer_t ALL_SPI_Transfer;
memset(&ALL_SPI_Transfer, 0, sizeof(ALL_SPI_Transfer));
// digitalWrite(csPin, LOW);
GPIO_PinWrite(BOARD_INITPINS_ECG_CS_GPIO,BOARD_INITPINS_ECG_CS_PORT,BOARD_INITPINS_ECG_CS_PIN,0U);

ECG_txBuffer[0] = dataToSend;
ALL_SPI_Transfer.txData = ECG_txdbuff;
ALL_SPI_Transfer.rxData = ECG_redbuff;
ALL_SPI_Transfer.dataSize = sizeof(ECG_txdbuff);
// Send out.
SPI_MasterTransferNonBlocking(ECG_PERIPHERAL, &ECG_handle, &ALL_SPI_Transfer);
while(!isFinished)
{
}
rdData = ECG_redbuff[0];
// digitalWrite(csPin, HIGH);
GPIO_PinWrite(BOARD_INITPINS_ECG_CS_GPIO,BOARD_INITPINS_ECG_CS_PORT,BOARD_INITPINS_ECG_CS_PIN,1U);
return (rdData);
}

 

 

标记 (3)
0 项奖励
回复
3 回复数

3,661 次查看
RaRo
NXP TechSupport
NXP TechSupport

Hello @TDC1333,

Just for double check, could you please check the initial configuration of the SPI peripheral and the pins configuration of MISO, MOSI, SCK, and SSELx? It might be useful to look at the SDK examples to compare with your configuration.

Also, could you please check if the SCK and MOSI signal at LPC54113 pins are working?

Your code seems functional; nonetheless, could you explain why you sent the image of ConfigTools configuration? Looking at it, you are missing SPI driver. If you are using ConfigTools you may want to add it for SPI initialization.

Best regards, Raul.

0 项奖励
回复

3,611 次查看
TDC1333
Contributor III

Hello Raul,

LPC54113 SCK and MOSI Pin are not working properly.SSEL Working Fine.SCK Not generating Colck and Master not sending data to MOSI Pin.

I have use SPI Driver.

Please check my SPI Configure for reference.PFA

Best Regard, TDC.

0 项奖励
回复

3,576 次查看
RaRo
NXP TechSupport
NXP TechSupport

Hello @TDC1333,

Testing your configuration, we noticed a missing line comparing it to the SDK examples that ConfigTools do not create for you in your configuration, and it is needed for the SPI communication to work.

Please try adding to your code, the following line SPI_MasterGetDefaultConfig(&userConfig) before SPI_MasterInit(ECG_PERIPHERAL, &ECG_config, ECG_CLOCK_SOURCE); 

The userConfig has to be configure as follows: spi_master_config_t userConfig; Let us know if this helps you to solve your problem.

Best regards, Raul.

0 项奖励
回复