| |
SPI programming - Write data to SPI
1. Add a new SPI
- Select "Application" tab.
- Add script as follows in order to add a new SPI.
| |
clear
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
| |
|
|
|
|
- Click "Send to MF Application" button or Press "F5" key.
- Executed result:
2. Write ushort data to SPI
- Use "Write(ushort data)" method to send ushort data to SPI.
- In order to create ushort typed variable, use "Util.ToUShort(object)" method.
- Select "Log" tab.
- Check "Display hex format for the SPI data"
- Select "Application" tab.
- Add script as follows.
| |
data = Util.ToUShort(0xB0A0)
spi1.Write(data)
| |
|
- Click "Send to MF Application" button or Press "F5" key.
- Emulator will log received data through SPI into log list. You can check this log from the Log tab.
- Select "Log" tab.
- Executed result:
3. Write byte data to SPI
- Use "Write(byte data)" method to send byte data to SPI.
- In order to create byte typed variable, use "Util.ToByte(object)" method.
- Select "Application" tab.
- Add script as follows.
| |
data = Util.ToByte(0xA0)
spi1.Write(data)
| |
|
- Click "Send to MF Application" button or Press "F5" key.
- Emulator will log received data through SPI into log list. You can check this log from the Log tab.
- Select "Log" tab.
- Executed result:
|