hello, I am use the MKE02Z32VLC4 as my MCU.The MCU has two SPI: SPI0 and SPI1. In SIM_PINSEL, there only SPI0 is mapped designated pins, and some software demoes don't have the definition about the SPI1，so I don't konw how to use the SPI1.could you tell me how to use the SPI1 or give some demo about it? thanks
SPI1 has a fixed set of pins and so doesn't use SIM_PINSEL as SPI0 can.
To use SPI1 instead of SPI0 you need to power it up in SIM_SCGC and access its registers in the SPI1 area (0x40077000, rather than SPI0 0x40076000). When SPI1 is enabled the pins are automatically configured as long as there is not a higher priority peripheral enabled that shares them. In the case of SPI1 there is in fact nothing with higher priority and so they are always connected.
The uTasker project does it as follows for controlling an SPI Flash interface, for example, including configuring the SPI1 controller:
POWER_UP_ATOMIC(SPI1); // enable clocks
SPI1_C1 = (SPI_C1_CPHA | SPI_C1_CPOL | SPI_C1_MSTR | SPI_C1_SPE);
SPI1_BR = (SPI_BR_SPPR_PRE_1 | SPI_BR_SPR_DIV_2);
SPI1_D = 0x55; // send a test byte...
And this can be verified in its simulator:
[uTasker project developer for Kinetis and i.MX RT]