SPL SPI programming - How to start SPI programming
1. Re-launch SPL emulator
- if SPL emulator is running, please terminate emulator.
- Press "F5" key to re-launch SPL emulator on the editor.
- Clear log on the log list.
- Check the checkbox named "Display hex format for the SPI data" on the Log tab.
2. Add "SPI" command
- SPL MF Emulator provides a SPI bus as follows.
- Id: spi1 ( Pin: 11 )
- Double click "SPI" item on the tree.
| |
SPI spi1
/ChipSelect_Port:11
/ChipSelect_ActiveState:false
/ChipSelect_SetupTime:1
/ChipSelect_HoldTime:1
/Clock_IdleState:true
/Clock_Edge:false
/Clock_RateKhz:15000
/SPI_Module:SPI1
| |
|
- You can change the ChipSelect_Port with the other pin number.
3. Add simple logic to send data to SPI bus
- You can send data to bus by using below method.
spiname.Write(byte data)
spiname.Write(ushort data)
spiname.Write(byte[] buff)
spiname.Write(ushort[] ubuff)
- Add lines to send data to bus as follows.
| |
SPI spi1
/ChipSelect_Port:11
/ChipSelect_ActiveState:false
/ChipSelect_SetupTime:1
/ChipSelect_HoldTime:1
/Clock_IdleState:true
/Clock_Edge:false
/Clock_RateKhz:15000
/SPI_Module:SPI1
data = Util.ToUShort(0x4040)
spi1.Write(data)
| |
|
- Click "Send Script" button to send SPL script to emulator.
4. Executed result
- Executed result will be shown as follows.
5. Read data from the SPI bus
- Continued in the next tutorial.
|