attila Posted September 7, 2015 Share Posted September 7, 2015 A custom asked the following: " is it possible to write a script to generate SPI data via the pattern generator? " Link to comment Share on other sites More sharing options...
attila Posted September 7, 2015 Author Share Posted September 7, 2015 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.dwf3work Link to comment Share on other sites More sharing options...
Question
attila
A custom asked the following:
" is it possible to write a script to generate SPI data via the pattern generator? "
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.