SPL SPI programming - How to start SPI programming


1. Re-launch SPL emulator
  1. if SPL emulator is running, please terminate emulator.

  2. Press "F5" key to re-launch SPL emulator on the editor.



  3. Clear log on the log list.

  4. Check the checkbox named "Display hex format for the SPI data" on the Log tab.



2. Add "SPI" command
  1. SPL MF Emulator provides a SPI bus as follows.
    1. Id: spi1 ( Pin: 11 )

  2. 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
    
      


  3. You can change the ChipSelect_Port with the other pin number.



3. Add simple logic to send data to SPI bus
  1. 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)

  2. 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)
    
      


  3. Click "Send Script" button to send SPL script to emulator.



4. Executed result
  1. Executed result will be shown as follows.




5. Read data from the SPI bus
  1. Continued in the next tutorial.