HI All,
I used the sdk but not the interrupt way.Please help me check the code why return 0.
Thank you very much.
THIS IS THE CODE:
int main(void)
{
gpio_pin_config_t gpio_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};
BOARD_ConfigMPU();
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
/*Set clock source for LPSPI*/
CLOCK_SetMux(kCLOCK_LpspiMux, EXAMPLE_LPSPI_CLOCK_SOURCE_SELECT);
CLOCK_SetDiv(kCLOCK_LpspiDiv, EXAMPLE_LPSPI_CLOCK_SOURCE_DIVIDER);
PRINTF("lpspi_functional_interrupt_board_2_board_master start.\r\n");
PRINTF("This example use one board as master and another as slave.\r\n");
PRINTF("Master and slave uses interrupt way. Slave should start first. \r\n");
PRINTF("Please make sure you make the correct line connection. Basically, the connection is: \r\n");
PRINTF("LPSPI_master -- LPSPI_slave \r\n");
PRINTF(" CLK -- CLK \r\n");
PRINTF(" PCS -- PCS \r\n");
PRINTF(" SOUT -- SIN \r\n");
PRINTF(" SIN -- SOUT \r\n");
PRINTF(" GND -- GND \r\n");
GPIO_PinInit(GPIO1, 2U, &gpio_config);
GPIO_PinWrite(GPIO1, 2U, 1U);
uint32_t srcClock_Hz;
uint32_t errorCount;
uint32_t i;
uint32_t whichPcs;
uint8_t txWatermark;
lpspi_master_config_t masterConfig;
/*Master config*/
masterConfig.baudRate = TRANSFER_BAUDRATE;
masterConfig.bitsPerFrame = 8;
masterConfig.cpol = kLPSPI_ClockPolarityActiveHigh;
masterConfig.cpha = kLPSPI_ClockPhaseFirstEdge;
masterConfig.direction = kLPSPI_MsbFirst;
masterConfig.pcsToSckDelayInNanoSec = 1000000000 / masterConfig.baudRate;
masterConfig.lastSckToPcsDelayInNanoSec = 1000000000 / masterConfig.baudRate;
masterConfig.betweenTransferDelayInNanoSec = 1000000000 / masterConfig.baudRate;
masterConfig.whichPcs = EXAMPLE_LPSPI_MASTER_PCS_FOR_INIT;
masterConfig.pcsActiveHighOrLow = kLPSPI_PcsActiveLow;
masterConfig.pinCfg = kLPSPI_SdiInSdoOut;
masterConfig.dataOutConfig = kLpspiDataOutRetained;
srcClock_Hz = LPSPI_MASTER_CLK_FREQ;
LPSPI_MasterInit(EXAMPLE_LPSPI_MASTER_BASEADDR, &masterConfig, srcClock_Hz);
unsigned char wData = 0;
uint32_t byte = 0;
unsigned char c = 0;
// c =((0x26 << 1) & ~(0x80));
c = (0x03 << 1) & 0x7E;
wData = (((0x03 << 1) & 0x7E ) | 0x80);
// wData = ((0x26 << 1) | 0x80);
while (1)
{
#if 1
LPSPI_WriteData(EXAMPLE_LPSPI_MASTER_BASEADDR, c);
LPSPI_WriteData(EXAMPLE_LPSPI_MASTER_BASEADDR, 0xFE);
LPSPI_WriteData(EXAMPLE_LPSPI_MASTER_BASEADDR, wData);
byte = LPSPI_ReadData(EXAMPLE_LPSPI_MASTER_BASEADDR);
// debug_printf("addr is 0x%x, spi data is 0x%x, return byte is 0x%x", addr, wData, byte);
PRINTF("byte = %d \r\n",byte);
#endif
}
}
Solved! Go to Solution.
Hi Tom,
You could refer to the LPSPI examples included on SDK v2.4.2 for IMXRT1050-EVKB board:
driver_examples->lpspi->lpspi_interrupt
driver_examples->lpspi->lpspi_interrupt_b2b_master
driver_examples->lpspi->lpspi_interrupt_b2b_slave
For additional details, you could refer to Chapter 30 “LPSPI: Low Power Serial Peripheral Interface” of the “MCUXpresso SDK API Reference Manual” document (attached), included on the Documentation package of the SDK.
Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Tom,
You could refer to the LPSPI examples included on SDK v2.4.2 for IMXRT1050-EVKB board:
driver_examples->lpspi->lpspi_interrupt
driver_examples->lpspi->lpspi_interrupt_b2b_master
driver_examples->lpspi->lpspi_interrupt_b2b_slave
For additional details, you could refer to Chapter 30 “LPSPI: Low Power Serial Peripheral Interface” of the “MCUXpresso SDK API Reference Manual” document (attached), included on the Documentation package of the SDK.
Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------