• 0

WaveForms 3 SPI master


Go to solution Solved by attila,

Question

1 answer to this question

Recommended Posts

  • 0
  • Solution
Yes. Here you have the script and attached the project:
// bit 0 - data, LSB first
// bit 1 - clk, sample on rising 
// bit 2 - select, active low
function setSPI(data, bits, hz){

   Patterns1.States.Repeat.value = 1
   Patterns1.States.RepeatTrigger.value = 0
   Patterns1.States.Run.value = (bits+1)/hz 
   // we need 2 samples for each SPI CLK
   Patterns1.Channels.Bus1.Frequency.value = 2*hz 

   var rg = new Array()
   rg.push(4) // select inactive high
   for(var i = 0; i < bits; i++, data>>=1){
      var f = data & 1
      rg.push(f) // set data 
      rg.push(f|2) // set clock
   }
   rg.push(4) // select inactive high
   Patterns1.Channels.Bus1._custom = rg
}

setSPI(0x8F, 8, 1000)
Patterns1.run()

PatternsSPI.png

PatternsSPI.dwf3work

Edited by attila
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now