MCUXpresso SDK Documentation

flexio_spi_polling_lpspi_transfer_master

flexio_spi_polling_lpspi_transfer_master#

Overview#

The flexio_spi_master_pooling_lpspi_slave example shows how to use flexio spi master driver in polling way:

In this example, a flexio simulated master connect to a lpspi slave.

Supported Boards#

EVKB-IMXRT1050
Hardware requirements
  • Mini/micro USB cable

  • EVKB-IMXRT1050 board

  • Personal Computer

Board settings

Remove the resistor R334 and weld 0Ω resistor to R278,R279,R280,R281.

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J24-4                SIN       SW5-3
SIN        J24-5                SOUT      SW5-2
SCK        J24-6                SCK       SW5-1
PCS0       J24-3                PCS0      SW5-4
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
MIMXRT1060-EVKB
Hardware requirements
  • Mini/micro USB cable

  • MIMXRT1060-EVKB board

  • Personal Computer

Board settings

Remove the resistor R305 and weld 0Ω resistor to R346,R350,R356,R362.

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J17-4                SIN       SW2-3
SIN        J17-5                SOUT      SW2-2
SCK        J17-6                SCK       SW2-1
PCS0       J17-3                PCS0      SW2-4
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
MIMXRT1170-EVKB
Hardware requirements
  • Mini/micro USB cable

  • MIMXRT1170-EVKB board

  • Personal Computer

Board settings

Remove 0Ω resistor to R200,R406.

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J10-10               SIN       J26-6
SIN        J10-8                SOUT      J26-4
SCK        J10-12               SCK       J26-2
PCS0       J10-6                PCS0      J26-8
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
MIMXRT1060-EVKC
Hardware requirements
  • Mini/micro USB cable

  • MIMXRT1060-EVKC board

  • Personal Computer

Board settings

Remove the resistor R305 and weld 0Ω resistor to R346,R350,R356,R362.

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J17-4                SIN       SW2-3
SIN        J17-5                SOUT      SW2-2
SCK        J17-6                SCK       SW2-1
PCS0       J17-3                PCS0      SW2-4
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
FRDM-IMXRT1152
Hardware requirements
  • Type-C USB cable

  • FRDM-IMXRT1152 board

  • Personal Computer

Board settings

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J11-10               SIN       J44-1
SIN        J11-8                SOUT      J44-3
SCK        J11-12               SCK       J44-5
PCS0       J11-6                PCS0      J44-7
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
EVK-MIMXRT1010
Hardware requirements
  • Mini/micro USB cable

  • EVK-MIMXRT1010 board

  • Personal Computer

Board settings

Remove the resistor R90 and weld 0Ω resistor to R800. To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J57-8                 SIN       J26-6
SIN        J57-10                SOUT      J26-4
SCK        J57-12                SCK       J26-8
PCS0       J57-6                 PCS0      J56-10
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.

Note: To debug in qspiflash, following steps are needed:

  1. Select the flash target and compile.

  2. Set the SW8: 1 off 2 off 3 on 4 off, then power on the board and connect USB cable to J41.

  3. Start debugging in IDE.

    • Keil: Click “Download (F8)” to program the image to qspiflash first then clicking “Start/Stop Debug Session (Ctrl+F5)” to start debugging.

EVK-MIMXRT1015
Hardware requirements
  • Mini/micro USB cable

  • EVK-MIMXRT1015 board

  • Personal Computer

Board settings

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J19-4                SIN       J18-5
SIN        J19-5                SOUT      J18-6
SCK        J19-6                SCK       J18-3
PCS0       J19-3                PCS0      J18-1
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.

Note: To debug in qspiflash, following steps are needed:

  1. Select the flash target and compile.

  2. Set the SW8: 1 off 2 off 3 on 4 off, then power on the board and connect USB cable to J41.

  3. Start debugging in IDE.

    • Keil: Click “Download (F8)” to program the image to qspiflash first then clicking “Start/Stop Debug Session (Ctrl+F5)” to start debugging.

EVK-MIMXRT1020
Hardware requirements
  • Mini/micro USB cable

  • EVK-MIMXRT1020 board

  • Personal Computer

Board settings

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J19-4                SIN       J18-5
SIN        J19-5                SOUT      J18-6
SCK        J19-6                SCK       J18-3
PCS0       J19-3                PCS0      J18-4
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.

Note: To debug in qspiflash, following steps are needed:

  1. Select the flash target and compile.

  2. Set the SW8: 1 off 2 off 3 on 4 off, then power on the board and connect USB cable to J23.

  3. Start debugging in IDE.

    • Keil: Click “Download (F8)” to program the image to qspiflash first then clicking “Start/Stop Debug Session (Ctrl+F5)” to start debugging.

MIMXRT1024-EVK
Hardware requirements
  • Mini/micro USB cable

  • MIMXRT1024-EVK board

  • Personal Computer

Board settings

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J19-8                SIN       J18-10
SIN        J19-10               SOUT      J18-12
SCK        J19-12               SCK       J18-6
PCS0       J19-6                PCS0      J18-8
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.

Note: To debug in qspiflash, following steps are needed:

  1. Select the flash target and compile.

  2. Set the SW8: 1 off 2 off 3 on 4 off, then power on the board and connect USB cable to J23.

  3. Start debugging in IDE.

    • Keil: Click “Download (F8)” to program the image to qspiflash first then clicking “Start/Stop Debug Session (Ctrl+F5)” to start debugging.

MIMXRT1040-EVK
Hardware requirements
  • Mini/micro USB cable

  • MIMXRT1040-EVK board

  • Personal Computer

Board settings

Weld 0Ω resistor to R346,R350,R356,R362.

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J17-4                SIN       SW2-3
SIN        J17-5                SOUT      SW2-2
SCK        J17-6                SCK       SW2-1
PCS0       J17-3                PCS0      SW2-4
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
EVK-MIMXRT1064
Hardware requirements
  • Mini/micro USB cable

  • EVK-MIMXRT1064 board

  • Personal Computer

Board settings

Remove the resistor R334 and weld 0Ω resistor to R278,R279,R280,R281.

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J24-4                SIN       SW5-3
SIN        J24-5                SOUT      SW5-2
SCK        J24-6                SCK       SW5-1
PCS0       J24-3                PCS0      SW5-4
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
MIMXRT1160-EVK
Hardware requirements
  • Mini/micro USB cable

  • MIMXRT1160-EVK board

  • Personal Computer

Board settings

Remove 0Ω resistor to R200,R406,R408,R404.

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SOUT       J10-10               SIN       J26-6
SIN        J10-8                SOUT      J26-4
SCK        J10-12               SCK       J26-2
PCS0       J10-6                PCS0      J26-8
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
MIMXRT1180-EVK
Hardware requirements
  • Mini/micro USB cable

  • MIMXRT1180-EVK board

  • Personal Computer

Board settings

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SCK        J44-12               SCK       J41-2
SIN        J44-10               SOUT      J41-6
SOUT       J44-8                SIN       J41-4
PCS0       J44-6                PCS0      J41-8
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
MIMXRT700-EVK
Hardware requirements
  • Micro USB cable

  • MIMXRT700-EVK Board

  • Personal Computer

Board settings

To make the example work, connections needed to be as follows:

 SLAVE(LPSPI16) connect to               MASTER(FlexIO0)
Pin Name   Board Location            Pin Name  Board Location
SOUT        J22 pin 6                SIN       J5 pin 3
SIN         J22 pin 5                SOUT      J5 Pin 6
SCK         J22 pin 4                SCK       J5 pin 4
PCS0        J22 pin 3                PCS       J5 pin 5
GND         J22 pin 8                GND       J6 pin 7
Prepare the Demo
  1. Connect a USB cable between the host PC and the MCU-LINK USB port on the board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.
FRDM-IMXRT1186
Hardware requirements
  • Type-C USB cable

  • FRDM-IMXRT1186 board

  • Personal Computer

Board settings

To make the example work, connections needed to be as follows:

        SLAVE           connect to      MASTER
Pin Name   Board Location     Pin Name    Board Location
SCK        J3-18                SCK       J1-6
SIN        J3-14                SOUT      J1-10
SOUT       J3-16                SIN       J1-8
PCS0       J3-12                PCS0      J1-12
Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

You can see the similar message shows following in the terminal if the example runs successfully.

FLEXIO Master - LPSPI Slave polling example start.
This example use one flexio spi as master and one lpspi instance as slave on one board.
Master uses polling and slave uses interrupt way.
Please make sure you make the correct line connection. Basically, the connection is:
FLEXIO_SPI_master -- LPSPI_slave
      CLK        --    CLK
      PCS        --    PCS
      SOUT       --    SIN
      SIN        --    SOUT

This is LPSPI slave call back.
FLEXIO SPI master <-> LPSPI slave transfer all data matched!
End of example.