to load data into a serial DAC, a separate latch pulse is needed at the end of an SPI transfer.
I tried to achieve this using a Custom SPI protocol and adding control for an extra output pin.
According to help file:
Quote
The Custom mode lets you write communication script with the following functions:
<snip>
* DIO.: Lets you set (the ones are not declared as SPI signal) and read the digital pins.
DIO.Set(DIO index 0..31, value 0/1/-1) value of -1 disables output, turns to high impedance the respective DIO channel
I modified an example script, but adding DIO.Set(31, 1) results in "Data transfer error", and WaveForms has to be restarted to recover from it.
// Pmod DA1 - AD7303
// DIO.Set(31,1); // <-- uncommenting this line results in "Data transfer error", need to restart WaveForms to recover
for(var i = 0; i < 50 & wait(0.1); i++){
var va = 128+sin(2*PI*i/50)*127;
var vb = 128+cos(2*PI*i/50)*127;
Start();
Write(16, 0x0100 | (va & 0xFF)); // Update DAC A input register from shift register
Stop();
Start();
Write(16, 0x2400 | (vb & 0xFF) ); // Load DAC B input register from shift register and update both DAC A and DAC B DAC registers outputs.
Stop();
// DIO.Set(31,0); // <-- uncommenting this line results in "Data transfer error", need to restart WaveForms to recover
wait(0.0001);
// DIO.Set(31,1); // <-- uncommenting this line results in "Data transfer error", need to restart WaveForms to recover
}
return "done"
Any suggestions to generate the desired signal? Any help is appreciated!
Question
Stefan-F
Hello,
to load data into a serial DAC, a separate latch pulse is needed at the end of an SPI transfer.
I tried to achieve this using a Custom SPI protocol and adding control for an extra output pin.
According to help file:
I modified an example script, but adding DIO.Set(31, 1) results in "Data transfer error", and WaveForms has to be restarted to recover from it.
// Pmod DA1 - AD7303 // DIO.Set(31,1); // <-- uncommenting this line results in "Data transfer error", need to restart WaveForms to recover for(var i = 0; i < 50 & wait(0.1); i++){ var va = 128+sin(2*PI*i/50)*127; var vb = 128+cos(2*PI*i/50)*127; Start(); Write(16, 0x0100 | (va & 0xFF)); // Update DAC A input register from shift register Stop(); Start(); Write(16, 0x2400 | (vb & 0xFF) ); // Load DAC B input register from shift register and update both DAC A and DAC B DAC registers outputs. Stop(); // DIO.Set(31,0); // <-- uncommenting this line results in "Data transfer error", need to restart WaveForms to recover wait(0.0001); // DIO.Set(31,1); // <-- uncommenting this line results in "Data transfer error", need to restart WaveForms to recover } return "done"
Any suggestions to generate the desired signal? Any help is appreciated!
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.