Search the Community

Showing results for tags 'spi'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • New Users Introduction
    • Announcements
  • Digilent Technical Forums
    • FPGA
    • Test and Measurement
    • Measurement Computing (MCC)
    • Add-on Boards
    • Digilent Microcontroller Boards
    • Non-Digilent Microcontrollers
    • LabVIEW
    • FRC
    • Other
  • General Discussion
    • Project Vault
    • Learn
    • Suggestions & Feedback
    • Buy, Sell, Trade
    • Sales Questions
    • Off Topic
    • Educators
    • Technical Based Off-Topic Discussions
    • Archived

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. // This posted here so that Google and Bing search the script to help other users of Digilent Analog Discovery AD2 // and Digilent wave forms find programming examples which are very difficult to find. // This driver is work in progress . SPI & I2C functionality not working yet . // for use with Digilent Analog Discovery AD2 script engine. // // Attila : Please leave this post up on the forum as I spent a very long time curating the script to find all the // small example pieces of code . // // ------------------------------------------------------------------------------------------------------------------- //************************************************************ // // Notes on the basic script syntax can be found here // // You can use the links in the Help, other educational pages or google... // // https://doc.qt.io/qt-5/ecmascript.html // // https://www.w3schools.com/jsref/jsref_obj_array.asp // // Note for this script to work the following Waveforms window panels have to be open // - Supplies - the internal AD2 PSU can be used // - Main script -- location where this script is cut and pasted // - Protocol ** - required to have acces to the AD2 internal SPI or UART or I2C bus engines // // edit using Notepad++ with the langauge Javascript selected. // // //************************************************************ //************************************************************ //Function blocks //************************************************************ function bitExtracted( number, k, p) { // Function to extract k bits from p position // and returns the extracted value as integer // eg first 11 bits of a 16 bit number // bitExtracted(int 0xfff,10,0) return (((1 << k) - 1) & (number >> (p - 1))); } function spi_initialise() { if(!('Protocol' in this)) throw "Please open the Protocol tool window"; //************************************************************ // Script using Protocol SPI. // SPI BUS Set up //************************************************************ // // SPI Bus physical wired set up // // Select AD_2_DIO3 // SPI: /CS // Clock AD_2_DIO4 // SPI: Clock // DQ0 AD_2_DIO5 // SPI: MOSI // DQ1 AD_2_DIO6 // SPI: MOS0 // // !! Remember to change the set up in function spi_pin_io_setup() if the SPI Pins are re assigned on the AD2 DIO GPIO pins !! Protocol.Mode.text = "SPI"; // make sure SPI tab is selected Protocol.SPI.Select.Active.value=0; Protocol.SPI.Clock.Polarity.value=0 ; // set up spi clock initial Polarity Protocol.SPI.Clock.Phase.value=0 ; // set up spi clock initial Phase Protocol.SPI.Clock.Frequency.value=1e6 ; // set spi clock freqncy at 1MHz page 19 of the data sheet min spi clock 1MHz if(Protocol.SPI.Clock.Frequency.value > 1e6) Protocol.SPI.Clock.Frequency.value = 1e6; Protocol.SPI.Select.value = 3; //Assigns pin Analog Disovery 2 GPIO Pin DIO 3 Protocol.SPI.Clock.value = 4; //Assigns pin Analog Disovery 2 GPIO Pin DIO 4 Protocol.SPI.DQ0.value = 5; //Assigns pin Analog Disovery 2 GPIO Pin DIO 5 // // SPI: MOSI Protocol.SPI.DQ1.value = 6; //Assigns pin Analog Disovery 2 GPIO Pin DIO 6 // SPI: MOS0 Protocol.config() // apply configuration changes now print(" SPI initialised " + "\n\r" ); print(" SPI Select is connect to AD2 DIO Port : " + Protocol.SPI.Select.value + "\n\r" ) ; print(" SPI Clock connect to AD2 DIO Port : " + Protocol.SPI.Clock.value + "\n\r" ) ; print(" SPU MOSI port connect to AD2 DIO Port : " + Protocol.SPI.DQ0.value + "\n\r" ) ; print(" SPU MOSO port connect to AD2 DIO Port : " + Protocol.SPI.DQ1.value + "\n\r" ) ; print("\n\r"+" SPI initialisation complete " + "\n\r" ) ; //************************************************************ // notes // ===== // // 1. On the AD and AD2 the digital IO pins use LVCMOS 3V3 standard. These are supplied at 3.3V and have 200 Ohm PTC and clamping diodes to GND and to 3.3V for protection. // It will drive the digital wires at 3.3V and connecting 5V signals directly, without series resistor, it will sink about 10mA through the PTC and 3v3 diode. // As for noise, make sure to have ground connection between the two devices. // // 2. The WF/Protocol/UART uses the Stop length option only for transmission, this is not relevant for reception. // // 3. The UART TX filed lets you type in characters, hexadecimal values are not supported here. // Special chars you can copy/paste from other place or send from file. //************************************************************ } function i2c_initialise() { if(!('Protocol' in this)) throw "Please open the Protocol tool window"; //************************************************************ // Script using Protocol I2C. // i2C BUS Set up //************************************************************ // // I2C Bus physical wired set up // // I2C SDA AD_2_DIO0 // I2C SCL AD_2_DIO1 // /Reset AD_2_DIO3 // // // // // Note Only DIO pins 0 through to 9 can be used for Protocol functions { SPI , I2C or UART} // // var I2C_reset_AD2_DIO_port = 3 ; // Set to AD2 DIO Port which controls I2C /Reset io line Protocol.Mode.text = "I2C"; // make sure SPI tab is selected Protocol.I2C.Mode.value = 1; //Set the I2C Protocol tool into Master Mode Protocol.I2C.SCL.value = 1; //Set the SCL pin to be DIO 0 Protocol.I2C.SDA.value = 0; //Set the SDA pin to be DIO 1 Protocol.I2C.SCL.Frequency.value = 100000; //Set the SCL clock frequency to 100 kHz //Protocol.I2C.Clockstretching.value = 1; //Enable Clock Stretching´.. This line is not functioning Protocol.I2C.ClockStretching.enable; // This is the replacement lines Protocol.config() // apply configuration changes now // flip the GPIO active low reset line set low then set high set_static_io_pin(I2C_reset_AD2_DIO_port,0); wait(0.1); // wait 100 milli second before next instruction. set_static_io_pin(I2C_reset_AD2_DIO_port,1); wait(0.1); // wait 100 milli second before next instruction. // ref https://forum.digilentinc.com/topic/4942-i2c-subaddress-not-working-properly-in-the-script-tool/ // Ref https://forum.digilentinc.com/topic/21906-how-to-measure-scope-and-protocol/ // ref https://forum.digilentinc.com/topic/18944-reading-i2c-via-script-displays-wrong-data/ print(" I2C initialised " + "\n\r" ); print(" I2C SCL connect to AD2 DIO Port " + Protocol.I2C.SCL.value + "\n\r" ) ; print(" I2C SDA connect to AD2 DIO Port " + Protocol.I2C.SDA.value + "\n\r" ) ; print(" I2C /RESET port connect to AD2 DIO Port " + I2C_reset_AD2_DIO_port + "\n\r" ) ; print("\n\r"+" I2C initialisation complete " + "\n\r" ) ; //************************************************************ // notes // ===== // // 1. On the AD and AD2 the digital IO pins use LVCMOS 3V3 standard. These are supplied at 3.3V and have 200 Ohm PTC and clamping diodes to GND and to 3.3V for protection. // It will drive the digital wires at 3.3V and connecting 5V signals directly, without series resistor, it will sink about 10mA through the PTC and 3v3 diode. // As for noise, make sure to have ground connection between the two devices. // // 2. The WF/Protocol/UART uses the Stop length option only for transmission, this is not relevant for reception. // // 3. The UART TX filed lets you type in characters, hexadecimal values are not supported here. // Special chars you can copy/paste from other place or send from file. //************************************************************ } function i2c_notes_read_with_i2c_sub_address() { // // Ref https://forum.digilentinc.com/topic/4942-i2c-subaddress-not-working-properly-in-the-script-tool/ // // // Special sub-addressing is only required for read operations. In this process the sub-address write is followed by a restart and read. // ref https://www.i2c-bus.org/repeated-start-condition/ // For write operations you can just concatenate the "sub-address" with the array of data you have to write. var a = [1,2] // sub-address var b = [3,4] // data var c = a.concat(b) Protocol.I2C.Write(0x48, c) } function i2c_write( address , data_array_to_write) { // // Examples of i2c_write // // address = 0x60 // data_array_to_write = [0,1] // Protocol.I2C.Write(address, data_array_to_write ) ; // notes // ===== // // 1. On the AD and AD2 the digital IO pins use LVCMOS 3V3 standard. These are supplied at 3.3V and have 200 Ohm PTC and clamping diodes to GND and to 3.3V for protection. // It will drive the digital wires at 3.3V and connecting 5V signals directly, without series resistor, it will sink about 10mA through the PTC and 3v3 diode. // As for noise, make sure to have ground connection between the two devices. // // 2. The WF/Protocol/UART uses the Stop length option only for transmission, this is not relevant for reception. // // 3. The UART TX filed lets you type in characters, hexadecimal values are not supported here. // Special chars you can copy/paste from other place or send from file. } function i2c_read( address , number_of_bytes_to_read_back ) { // // Examples of i2c_read // // address = 0x60 // number_of_bytes_to_read_back =32 // var bytes = Protocol.I2C.Read( address, number_of_bytes_to_read_back) ;// returns array of x bytes read from device address 0x0D return bytes ; } function i2c_read_example() { // From the Script tool you can perform I2C transfer like this: var bytes = Protocol.I2C.Read(0x0D, 2) ;// returns array of 2 bytes read from device address 0x0D var temp = (((bytes[0]<<26) | (bytes[1]<<18)) >>18)/32; print("Temp: "+temp+"*C") // ref https://forum.digilentinc.com/topic/17333-digital-discovery-logic-dios-are-different-to-dios-from-the-patterngenerator/ } function spi_pin_io_setup() { print(" The SPI setup should be :- "); print(" "); print(" Select AD_2_DIO3 // SPI: /CS "); print(" Clock AD_2_DIO4 // SPI: Clock "); print(" DQ0 AD_2_DIO5 // SPI: MOSI "); print(" DQ1 AD_2_DIO6 // SPI: MOS0 "); } function UART_initialise() { clear(); // clear Output log // // Note Only DIO pins 0 through to 9 can be used for Protocol functions { SPI , I2C or UART} // // if(!('Protocol' in this)) throw "Please open the Protocol instrument"; Protocol.Mode.text = "UART"; // make sure UART tab is selected Protocol.UART.TX.value = 0; // Set up UART TX pin on Digilent AD2 :: DIO_0 Pin Protocol.UART.RX.value = 1; // Set up UART RX pin on Digilent AD2 :: DIO_1 Pin Protocol.UART.Bits.value=8; // Sets or gets the UART number of bits. Protocol.UART.Parity.text="None" ;// Sets or gets the parity setting: “None”, “Even”, “Odd”, “Mark (High)”, “Space (Low)”. Protocol.UART.Rate.value=9600; // Sets or gets the baud rate setting Protocol.config(); // apply configuration changes now Protocol.UART.Receiver(); // reset receiver - that is too start receiving data print(" UART Serial Bus initialised . Beware this is 3V3 Logic RS232 & Not True +/- 15V Rs232" + "\n\r" ); print(" I2C SCL connect to AD2 DIO Port " + Protocol.I2C.SCL.value + "\n\r" ) ; print(" I2C SDA connect to AD2 DIO Port " + Protocol.I2C.SCL.value + "\n\r" ) ; print("\n\r"+" I2C initialisation complete " + "\n\r" ) ; // // ref https://forum.digilentinc.com/topic/21308-ad2-protocol-uart-script-reading-vaillant-ebus/ // // https://forum.digilentinc.com/topic/21353-use-of-multiple-protocol-uart-ports-via-script-possible-at-different-times/ // // notes // ===== // // 1. On the AD and AD2 the digital IO pins use LVCMOS 3V3 standard. These are supplied at 3.3V and have 200 Ohm PTC and clamping diodes to GND and to 3.3V for protection. // It will drive the digital wires at 3.3V and connecting 5V signals directly, without series resistor, it will sink about 10mA through the PTC and 3v3 diode. // As for noise, make sure to have ground connection between the two devices. // // 2. The WF/Protocol/UART uses the Stop length option only for transmission, this is not relevant for reception. // // 3. The UART TX filed lets you type in characters, hexadecimal values are not supported here. // Special chars you can copy/paste from other place or send from file. } function UART_Test() { UART_initialise(); Protocol.UART.Receiver(); // start receiver wait(); Protocol.UART.Send("hello"); // TX wait(0.1); // 100ms wait for RX, depends on the external device and rate print(Protocol.UART.Receive()); // RX } function UART_Test_example_2() { UART_initialise(); Protocol.UART.Receiver(); // reset receiver - that is start receiving data var rx = []; while(wait(1)) { // wait 1 sec and repeat while not stopped rx = rx.concat(Protocol.UART.ReceiveArray()); // append new words while(rx.length>10) { if(rx.shift()==0xAA) continue; if (rx[1] == 0xB5 && rx[2]== 0x11 && rx[7] == 0x09) { // find the temperatures for displaying print ("Temp 1: " + (rx[8]/2).toFixed(1) + " °C Temp 2: " + (rx[9]/2).toFixed(1) + " °C"); // decimal data devided by 2 bring °Celsius } } } } function UART_Test_example_3() { UART_initialise(); Protocol.UART.Receiver(); // reset receiver - that is start receiving data // Protocol.UART.Send("Hello") ; // send text with ending var rx = Protocol.UART.Receive(); // receive text print(rx) ; // Protocol.UART.Send("Hello ", false); // send text custom ending var rx = Protocol.UART.Receive(); // receive text print(escape(rx)); // Protocol.UART.SendArray([1,2,3,4,5,0], false); // send array custom ending var rx = Protocol.UART.ReceiveArray(); // receive array print(rx); } function spi_write( address , data_to_write) { Protocol.SPI.Start(); Protocol.SPI.Write( address ,data_to_write ); // Read Register, Device ID Protocol.SPI.Stop(); wait(0.1); // wait 100 milli second before next instruction. } function spi_write_read( address , data_to_write, number_of_bytes_to_read_back) { Protocol.SPI.Start(); Protocol.SPI.Write( address ,data_to_write ); // Read Register, Device ID wait(0.1); // wait 100 milli second before reading data. var rg_data = Protocol.SPI.Read(address, number_of_bytes_to_read_back); Protocol.SPI.Stop(); wait(0.1); // wait 100 milli second before next instruction. return rg_data ; } function static_io_example() { // ref https://forum.digilentinc.com/topic/21512-how-to-energize-multiople-staticio-given-only-when-a-certain-dio-is-on/ // ref https://forum.digilentinc.com/topic/2150-staticio-scripting-documentations-for-waveforms3/ // ref https://forum.digilentinc.com/topic/18737-export-issues/ // ref https://forum.digilentinc.com/topic/18789-some-functional-problems/ clear() if(!('StaticIO' in this)) throw "Please open the StaticIO instrument"; const IO = 7; const delay = 0.3; print("Running StaticIO script"); for(var c = 0; c <= IO; c++) { StaticIO.Channel0.DIO[c].Mode.text = "Switch"; } StaticIO.run() while(wait()){ // while script not stopped if(StaticIO.Channel1.DIO8.Input.value == 1) { for(var c = 0; c <= IO; c++) { StaticIO.Channel0.DIO[c].text = "1"; StaticIO.config(); // apply changes now if(!wait(delay)) return; // exit on script stop StaticIO.Channel0.DIO[c].text = "0"; StaticIO.config(); if(!wait(delay)) return; } for(var c = IO; c > 0; c--) { StaticIO.Channel0.DIO[c-1].text = "1"; StaticIO.config(); if(!wait(delay)) return; StaticIO.Channel0.DIO[c-1].text = "0"; StaticIO.config(); if(!wait(delay)) return; } } } } function static_io_example_2() { // ref https://forum.digilentinc.com/topic/21512-how-to-energize-multiople-staticio-given-only-when-a-certain-dio-is-on/ // ref https://forum.digilentinc.com/topic/2150-staticio-scripting-documentations-for-waveforms3/ // ref https://forum.digilentinc.com/topic/18737-export-issues/ // ref https://forum.digilentinc.com/topic/18789-some-functional-problems/ clear(); if(!('StaticIO' in this)) throw "Please open the StaticIO instrument"; // 1.Probe print("Running pin 1, channel 1") StaticIO.Channel0.DIO[3].text = "0"; StaticIO.Channel0.DIO[4].text = "1"; StaticIO.Channel0.DIO[5].text = "1"; StaticIO.Channel0.DIO[0].text = "0"; StaticIO.Channel0.DIO[1].text = "0"; StaticIO.Channel0.DIO[2].text = "0"; StaticIO.config(); // force immediate configuration wait(1); // wait on external device/circuit } function static_io_example_3() { // // This is what's available on the wiki: // // .StaticIO // // .Channel#: groups of 8 signals // .Mode.text: select between: I/Os, Slider, Progress // .Input.value: input value // .DIO#: I/Os // .Input.checked: input value // .Mode.text: select between: LED, Button, Switch // .Button.text: select between: 0/1, 1/0, Z/1, 1/Z, Z/0, 0/Z // .Switch.text: select between: TS, PP, OS, OD // ref https://forum.digilentinc.com/topic/2150-staticio-scripting-documentations-for-waveforms3/ // I got the DIO13 configured as a PushPull Switch, but how do you set the actual value that you want the pin to output? // Configure Static IO StaticIO.Channel1.Mode.text = "I/Os" // Configure Red LED StaticIO.Channel1.DIO13.Mode.text = "Switch" StaticIO.Channel1.DIO13.Switch.text= "PP" } function set_static_io_pin( AD2_Dio_pin , boolean_state ) { if(!('StaticIO' in this)) throw "Please open the StaticIO instrument"; if( boolean_state == 1) { StaticIO.Channel0.DIO[AD2_Dio_pin].text = "1"; StaticIO.config() // force immediate configuration } if( boolean_state == 0) { StaticIO.Channel0.DIO[AD2_Dio_pin].text = "0"; StaticIO.config() // force immediate configuration } } function power_up_psu( Power_supply_voltage ) { //************************************************************ // Set up mini PSU inside Analogue Discovery 2 to supply 3.3V //************************************************************ if(!('Supplies' in this)) throw "Please open the Supplies tool window"; Supplies.Output.PositiveSupply.Voltage.value=Power_supply_voltage; Supplies.Output.PositiveSupply.Enable.setEnable(); Supplies.Output.NegativeSupply.Enable.setDisable(); Supplies.run(); // Turn on PSU unit inside AD2 print(" Power supply is UP VCC = " + Power_supply_voltage + "\n\r" ); wait(5); // wait 1 seocnds for system to stabilise. //*********************************************************** } function power_down_psu() { //************************************************************ // Power down mini PSU inside Analogue Discovery 2 to supply 3.3V //************************************************************ print(" PSU is powering down" ); Supplies.stop(); wait(5); // wait 5 second before reading data. Supplies.Output.PositiveSupply.Voltage.value=0.3; Supplies.Output.PositiveSupply.Enable.setEnable(); Supplies.Output.NegativeSupply.Enable.setDisable(); Supplies.run(); // Turn on PSU unit inside AD2 wait(10); // wait 10 second before reading data. Supplies.stop(); // Turn off PSU unit inside AD2 after measurment has finished. print(" PSU is powered down" ); //*********************************************************** } function PMOD_ADXL362_not_working() { //************************************************************ // Example block read ADXL362 Device ID : Start //************************************************************ clear(); // clear display screen print(" SPI Script for PMOD ACL2 3 axis accelometer with Analog devices ADXL362 running " + "\n\r "); power_up_psu( 3.3 ) ; // Power up PSU to VCC = 3v3 spi_initialise(); // set up spi bus var STATUS_reg =spi_write_read( 8, [0x0B, 0x00], 1) ; // Read ADXL362 STATUS_reg Page 23 & 25 of the ADXL362 Data sheet & read 1 words of 8 bit length print(" ADXL362 Status regiser raw data after reset = " + STATUS_reg + "\n\r" ); wait(0.01); // wait 10 milli second before reading data. var rgID = spi_write_read( 8, [0x0B, 0x00], 4) ; var Device_ok=0; if(rgID[0] != 0xAD || rgID[1] != 0x1D || rgID[2] != 0xF2){ print(" Device ID mismatch rgid(0) " + rgID[0] ); print(" Device ID mismatch rgid(1) " + rgID[1] ); print(" Device ID mismatch rgid(2) " + rgID[2] ); print(" "); print(" Is the physical SPI Bus physical wired set up correctly ?? " ); print(" "); spi_pin_io_setup(); } else { print(" Device is ADXL362 : SPI register 0x00 read { 0dxx in decimal} : " + rgID + "\n\r" ); Device_ok=1; } //********************************************************************************** // // Result shoudl be : Read: hAD, h1D, hF2, h02, // Output : 173,29,242,2 in dec --> hex --> 0xAD 0x1D 0xF2 Ox02 // //********************************************************************************* if ( Device_ok==1) { /*--------------------------------------------------------------------------------------------------------------- * * ADXSL262 SPI register setup for POWER_CTL to be permantly on without sleep * * Bit 7 Reserved 0x0 * Bit 6 External CLK =1 int=0 0x0 * Bit 5:4 Power ns Noise Trade off 0x10 = Ultra Low Noise * Bit 3 Wakeup mode 0x0 = OFF * Bit 2 Autosleep 0x0 = OFF * BIT 1:0 Measurement state 0x10 = Measurment Mode * * Resultant setting = b00 10 00 10 = 0x22 *---------------------------------------------------------------------------------------------------------------*/ spi_write( 8,[0x0A, 0x2D, 0x02] ); // Power Control Register, Measurement Mode var rg = spi_write_read( 8, [0x0B, 0x0E], 8) ; // convert data bits to signed value relative to gravitational constant // MSbit sign, LSBit 0.001g for default 2g mode var gx = (0.001* ((rg[1]<<28) | (rg[0]<<20)) /1048576).toFixed(3); var gy = (0.001* ((rg[3]<<28) | (rg[2]<<20)) /1048576).toFixed(3); var gz = (0.001* ((rg[5]<<28) | (rg[4]<<20)) /1048576).toFixed(3); var tp = (0.065* ((rg[7]<<28) | (rg[6]<<20)) /1048576).toFixed(2); print(" Raw data {16 bit data} {x,y,z,temp} = " + rg + "\n\r" ); print(" Accelerometer initial X value = " + gx ); print(" Accelerometer initial y value = " + gy); print(" Accelerometer initial z value = " + gz); print(" Accelerometer initial temp value = " + tp); } } //************************************************************ // Main program block : Start //************************************************************ clear(); // clear display screen print(" Script Main body start " + "\n\r "); power_up_psu( 3.3 ) ; // Power up PSU to VCC = 3v3 // ********************** // User code start // ********************** // ********************** // User code stop // ********************** power_down_psu(); //************************************************************ //************************************************************ // Main program block : Stop End //************************************************************ Digilent_AD2_Script_master.js
  2. I just want to read back something besides 0x00 on my raspberry pi. Is it possible to adjust the MISO to be 0xAA for example? This is with respect to the WaveForms program under the Logic sub menu. The Analog discovery is showing me what the Master is writing (DEADBEEF), so I am confident I have hooked things up correctly. I'm not sure if this is even possible, please feel free to correct me either way. Edit: I found the protocol submenu where I can write custom scripts, this will probably achieve what I want. I will add what I find to this topic if I get it working.
  3. Hello, I need help I work on the pmodgyro, and I've been trying to get the temperature for several days but I can't. I use the stm32. and I even tried with the arduino it does not work. I think I may have fried it as I use i2c communication and I often fail to use resistane pull-up. I would like to have concrete suggestions to test the sensor please, Thank you
  4. Hi, I am using protocol analyzer to monitor a SPI bus.. I have a STM32MCU used as SPI master, configured to run full duplex communication. There is no slave connected and I am just trying to understand the protocol itself. It is configured the following way: CPHA = 0, CPOL = 0 I have plugged the 1st Probe(Orange) to the CLK and 2nd Probe(Blue) to the MOSI pins and I record the waveform, Parallelly I have made the following connections to the digital inputs to record them on the Protocol analyzer DI 1(Green Wire) -> CLK DI 2(Purple Wire) -> MOSI The purpose of this connection is to monitor the CLK and DATA out from the SPI using Scope and Protocol analyzer. The logic I have written in the STM32MCU is to send a value "0x1" out via SPI pin whenever a push button is pressed. Below is the image of the data out from SPI that is captured in scope, the data out from the MCU is correct, every time I press the push button(SW delay is provided to prevent debouncing) However I observe a different pattern while Spying the bus using protocol analyzer. I see the data being shifted every time I press the button(Image Below). You can see that the "11" values are being shifted every time I press the push button. The data transmitted is wrong (It sends "11" instead of 1) My question is, if the data is shifted in the protocol analyzer window why bit shifting does not show on the scope?
  5. Hello everyone, I am looking for an ADC and a DAC of at least 2 MSPs and a resolution greater than or equal to 12 bits. I do not want to use ADC or DAC with an FMC type interface (I do not have enough free pins on my FPGA card). A serial type interface (SPI) would be nice. Are there PMODs that have these characteristics? If not, can you recommend an ADC / DAC with these characteristics (> 2 MSPs and> 12 bit resolutions)? I have to process signals of frequency <= 10 kHz and send them to a DAC with a resolution of at least 12 bits and an acquisition speed of at least 2 MSPs. Thank you! Regards H
  6. azn103

    Cmod S6 Quad Spi

    I recently got a Cmod S6 and was able to program it just fine. Now I want to access the Quad SPI so I can load my program directly from the SPI rather than using the Digilent Adept program. The Cmod S6 did not show any references to how to program that part. How do you program the PROM?
  7. I am trying to use the PmodCAN module together with PetaLinux on the ZedBoard, to display a CAN interface within the OS. So far I can make it show up in the interface overview with the following device tree overlay: /* <petalinux-project-root>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi */ /include/ "system-conf.dtsi" / { osc: can_osc { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <20000000>; }; }; &gpio0 { #interrupt-cells = <2>; interrupt-controller; }; &spi1 { is-decoded-cs = <0>; num-cs = <1>; status = "okay"; spidev@0x00 { compatible = "microchip,mcp25625"; spi-max-frequency = <10000000>; clocks = <&osc>; interrupt-parent = <&gpio0>; interrupts = <0 0x2>; reg = <0>; } }; I can even send and receive messages using `candump` and `cansend`, but the interface behaves strange together with some CAN libraries. E.g. Messages are sometimes not sent, when the library tries to send multiple messages without any delay between them. On the other hand, when I connect the PmodCAN to a RaspberryPi and use same said libraries, everything works fine. So the only difference I can see between the working Raspberry Pi and the "strange" behaving Zynq setup, is the manually defined device tree overlay you see above. Long story short: Is my device tree overlay for the PmodCAN correct, to use it together with the ZedBoard on the JE Pmod connector? Maybe there is even a template somewhere? Based on the issues I have, I suspect something might be wrong with the clock and frequency definitions ...
  8. Dear Attila Please find enclosed the following . This took more than 4 hours to prepare all the documentation please treat as such. I am using the latest version of Digilent Waveforms and the latest Waveforms SDK. - Master Javascript driver for Digilent Analogue Discover AD2 which can be used inside Waveforms - SPI Setup , read & write & Initialise (1) . Status NOT Working . Needs Digilent Help to fix (%%) - I2C Setup , read & write & Initialise (2) . Status NOT Working . Needs Digilent Help to fix - UART Setup , read & write & Initialise(3) . ** - GPIO Setup, Set individual GPIO Pin Output States (4) Working - PSU Control, Set PSU voltage , turn on and off (5) Working - Python driver directly to control ON-SEMI CAT9532 using Digilent Analogue Discover AD2 & Digilent Waveforms ## Enclosed are all the attached scripts . ** Mostly likely works as driver details taken from working examples . See driver for while for web links reference. (%%) See previous efforts here to get it working &nbsp; &nbsp;https://forum.digilentinc.com/topic/21997-waveforms-with-accelerometer-digilent-analog-discovery-2-with-pmod-acl2-java-script-spi/#comment-63633 https://forum.digilentinc.com/topic/19237-waveforms-with-accelerometer/page/2/#comment-52495 I am trying to get the I2C driver function of the AD2 to work to drive a ON-SEMI CAT9532 LED driver. Set up , I have two Digilent Analogue Discover AD2 - Device 1 : Digilent AD2 (Device A) I2C driver source . A) Device is programed using Digilent Waveforms Javascript B) Direct control though Digilent Waveforms I2C Master interface C) Direct control though Digilent Waveforms I2C Master script interface D) Direct control Waveforms SDK & Python - Device 2 : Dilenet AD2 (Device B) as I2C spy device - Device 3 : TotalPhase Advark I2C/SPI professional I2C development tool Direct control & Programming by XML program script. https://www.totalphase.com/products/aardvark-i2cspi/ I own (2) two Analogue Discovery devices. What worked Device 2 : It could work perfectly as a I2C spy mode device Device 3: Worked perfectly straight out of the box using the GUI interface. Took 20 mins to have working solution. This is professional I2C product that has been in the market for 10 years plus. What failed Device 1: Did not output the correct I2C packet no mater how it was programmed. Device 1 : Had 10K pull up resistor attached to the VCC 3V3 rail on the I2C: SDA & I2C:SCL & I2C:/RESET. Conclusion There seems to be general issue with the AD2 and getting it to work as driver for I2C and SPI . Which is a long term issue. I have spent a long time searching for all the small details to build up the driver set so that should work with Digilent Analogue Discover AD2 & Digilent Waveforms but if the hardware of the AD2 is not co-operative or the staff in Digilent not being supportive there is only so much I can do . Requested Help 1. Fix the Waveforms AD2 Javascript and Python Waveforms SDK so it works for SPI & I2C . There is something missing here, where it would be good to fix to improved your AD2 products for the whole community of AD2 users 2. Have a Digilent published AD2 drivers that work for SPI & I2C & UART & GPIO & PSU control for waveforms and waveforms SDK. So Attila the case is in your lap now .. Please put some effort in to fix it or show me how to fix it . I have the feeling your quite a skilled person. The result should be posted here as a product example : https://projects.digilentinc.com/products/waveforms?sort=updated Background I am a electronic engineer with 20+ years development experience , I have have successfully used Digilent AD2 to design 3 products end to end and have been using it for quite a few years. I can program in Python , Microsoft VB.net and Javascript. I have personally purchased two pieces of AD2 out of my own money as feel they are such a good tool. I am committed to using the AD2 as I can see and experience that it is a super swiss army knife for use in a development of embedded electronics. I have also purchased a full profesional copy of National instruments Labview for use with AD2 but , have suspended learning to use labview until this I2C & SPI issue is resolved with the AD2 Digilent_AD2_Script_I2C_control_of_on-semi_CAT9532.py Digilent_AD2_Script_I2C_control_of_on-semi_CAT9532.js Digilent_AD2_Script_I2C_control_of_on-semi_CAT9532.dwf3work Digilent_AD2_Script_master.js
  9. Hi With the waveforms tool is it possible using python scripting in the Waveforms platform to do the following ?? Use the Digilent Analogue discovery 2 - Attach a device like a PMOD device eg accelerometer https://store.digilentinc.com/pmod-acl-3-axis-accelerometer/ using the Analogue discovery 2 ability to chat SPI & IC2 - pmod DEVICES SUPPORT 12-pin Pmod connector with SPI interface and 2×4-pin I²C interface - Then using the read information from the PMOD device treat it like an extra oscilloscope channel . Either as a Analog channel or Digital channel depending on the the signal type acquired from the PMOD device. This is possible with Labview but that would also require a lot of code writing. If this is possible this is outstanding feature when considering all the available PMOD devices available from the list https://store.digilentinc.com/by-function/input/ This would be a real product enhancement for Digilent and the Analog Discovery and help sell the AD2 in to many new places . Best wishes Simon
  10. Hi Attila Have you have had almost 2 years to paste up a working example of how to get a PMOD ACL2 working but I still can not finding a working example any where. This is the latest code for from the last time Is there any chance you will actually spend the time to get this to work .. I feel it is not so good that a good tool like AD2 is being not supported. Best wishes & friendly greetings SIB Direct_protocol_test.dwf3work SPI_test.dwf3work SPI_test_2.dwf3work SPI_test_3.dwf3work SPI_test_4.dwf3work SPI_test_5_test.dwf3work
  11. 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!
  12. Hello, I have connected the AD2 to Spy on an existing SPI Bus between a STM Controller and an IC provided by our Company, and am trying to just spy and log the traffic for tool verification reasons. When i use the Setup with the Waveforms GUI, everything works fine. It displays all Samples, the data looks ok, everything fine. As soon as I start using the tool via API (Python or C#, happens on both) the SPI Phase Settings seems to get ignored. I get flipping Bits all over the place, which is the same behaviour as if i set the Phase in the Waveforms GUI (Waveforms -> Protocol -> SPI) to the wrong setting. The correct Setting for my application is polarity=0 and phase=1, so I used FDwfDigitalSpiModeSet with it's parameter set to 1. I attached the C# and Python programs below for reference, maybe i overlooked something in there, but wouldn't know what should be wrong with it... Program.cs spi_tracker.py
  13. pedro_uno

    MRAM PMOD

    Hello, I need to develop software to control an Magnetoresistive RAM (MRAM). I searched for an MRAM PMOD and found this item out of stock. https://www.tindie.com/products/alliedcw/pmod-mram-nonvolatile-memory/ The picture shows a Digilent board but I do not find it on your website. Do you have any of these on hand? Why don't they show on your site? Pete
  14. If I configure the SPI with mode 0 (polarity=0 and phase=0) and LSB in WaveForms SDK in the Digital Discovery or Analog Discovery 2, and I send the byte 163=0xA3=b10100011; I would see the following: Is it guaranteed that when there is a falling edge of SCLK, the MOSI takes the value just before the transition (the SCLK edge)? What I mean is; is the following image accurate:
  15. I have a device that has a single 16-bits SPI shift register (for both transmissions and receptions). It responds to falling edges of SCLK. The input of the shift register is connected to MOSI and the output to MISO, as the following figure. As the MOSI signal is input to the first flip-flop of the shift register, it should remain stable (not change) during a falling edge of SCLK, while MISO changes its value during a falling edge of SCLK. This way, MISO and MOSI signals are not synchronized. I want to communicate with this device using WaveForms SDK. Is there a way to configure the SPI communication correctly? With this I mean: is there a way of generating the SCLK and MOSI signals as shown in the figure above, and sample the MISO data in each rising edge of the SCLK? I suspect functions FDwfDigitalSpiRead16 and FDwfDigitalSpiWrite16 assume MISO and MOSI signals are synchronized; so no SPI polarity and phase configuration would work correctly.
  16. What is the good method transfering the eight bits via SPI to DPOT using a raspberry pi? spi.writebytes accepts int arrays only. many thnaks
  17. I am programming a Digital Discovery with WaveForms SDK (in Python) to communicate via SPI with an FPGA. The SPI comunication has 16 bit words. First, I have to send the address to read or write (the first bit of the 16 bit word indicates whether it is a read 0 or a write 1). Then, in the second 16 bit word, I read the data if it was a read operation, or I send the data if it was a write operation. I have the following code: # Imports from ctypes import * from dwfconstants import * import sys import time # Load dwf library if sys.platform.startswith("win"): dwf = cdll.LoadLibrary("dwf.dll") elif sys.platform.startswith("darwin"): dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf") else: dwf = cdll.LoadLibrary("libdwf.so") # Open the Digital Discovery device hdwfDD = c_int() dwf.FDwfDeviceOpen(c_int(-1), byref(hdwfDD)) # Configure digital voltage to 1.8 V and system frequency to 100 MHz dwf.FDwfAnalogIOChannelNodeSet(hdwfDD, c_int(0), c_int(0), c_double(1.8)) dwf.FDwfAnalogIOChannelNodeSet(hdwfDD, c_int(0), c_int(6), c_double(100e6)) dwf.FDwfAnalogIOEnableSet(hdwfDD, c_int(True)) # Configure SPI dwf.FDwfDigitalSpiFrequencySet(hdwfDD, c_double(1e6)) # 1 MHz dwf.FDwfDigitalSpiClockSet(hdwfDD, c_int(4)) dwf.FDwfDigitalSpiDataSet(hdwfDD, c_int(0), c_int(6)) # MOSI dwf.FDwfDigitalSpiDataSet(hdwfDD, c_int(1), c_int(15)) # MISO dwf.FDwfDigitalSpiModeSet(hdwfDD, c_int(0 | (0 << 1))) # Polarity 0; Phase 0 dwf.FDwfDigitalSpiOrderSet(hdwfDD, c_int(0)) # LSB # Configure the address 1 to value 5000 time.sleep(200e-6) dwf.FDwfDigitalSpiWriteOne(hdwfDD, c_int(1), c_int(16), c_int(0x8000 | 1)) time.sleep(200e-6) dwf.FDwfDigitalSpiWriteOne(hdwfDD, c_int(1), c_int(16), c_int(5000)) # Read the value in address 1 to check if data has been set correctly time.sleep(200e-6) dwf.FDwfDigitalSpiWriteOne(hdwfDD, c_int(1), c_int(16), c_int(1)) time.sleep(200e-6) rxData = c_int() dwf.FDwfDigitalSpiReadOne(hdwfDD, c_int(1), c_int(16), byref(rxData)) All the dwf functions return 1 (including dwf.FDwfDigitalSpiWriteOne). I have also checked that the SPI writes are working with an oscilloscope. The problem is with the function dwf.FDwfDigitalSpiReadOne, that returns 0. What does this mean? Besides, when this function is executed, the Digital Discovery turns on a blue LED. What is the meaning of this blue LED? I have run the following code after the unsuccessful DigitalSpiReadOne trying to obtain an error message: szerr = create_string_buffer(512) dwf.FDwfGetLastErrorMsg(szerr) print(str(szerr.value)) # Prints: b'' But nothing is printed. I want to add that the same SPI configuration works perfectly in an Analog Discovery 2. The problem is I want the SPI to work at 1.8 V, and as far as I know, the Analog Discovery 2 only works at 3.3 V.
  18. I want to do the following with WaveForms SDK: communicate through 1.8 V SPI read 2 digital 1.8 V inputs generate a digital 1.8 V output generate a digital clock of 32768 Hz (low level 0 V and high level 1.8 V) Is this possible with a Digital Discovery or with an Analog Discovery 2 (or both)? I wanted to use an Analog Discovery 2, but I think I cannot set the digital voltage to 1.8 V (it is always 3.3 V). On the other hand, I do not know if a Digital Discovery does the trick, since: (Source: https://reference.digilentinc.com/reference/software/waveforms/waveforms-sdk/reference-manual#digital_protocols) This means that I cannot communicate through 1.8 V SPI and read digital inputs/write digital outputs; am I right?
  19. Dear All, Board in use: ARTY A7-100T Flash in use: FL128SAIF00 Spansion Goal: to write 10 bytes of user data to flash and then read it later to use it in code. Present status : I am using microblaze , along with axi quad spi, mig , clock wizard, small PL logic etc. in my block design. I am able to program the flash and I am able sucessfully use bootloader to load the srec image from flash when the board powers up. So flash reading/ writing is working for this purpose. Now I want to simply write few bytes to flash and then read it from microblaze code. For this I followed a link found on this forum: https://github.com/Xilinx/embeddedsw/blob/master/lib/sw_services/xilisf/examples/xilisf_spips_sst_polled_example.c?_ga=2.258985923.834060548.1609139438-288455063.1605863153 I made small changes to the code to suit my requirements and now it looks like this: #include "xparameters.h" /* EDK generated parameters */ //#include "xscugic.h" /* Interrupt controller device driver */ #include "xil_exception.h" #include "xil_printf.h" #include "xplatform_info.h" #include <xilisf.h> /************************** Constant Definitions *****************************/ /* * The following constants map to the XPAR parameters created in the * xparameters.h file. They are defined here such that a user can easily * change all the needed parameters in one place. */ #define SPI_DEVICE_ID XPAR_SPI_0_DEVICE_ID /* * The following constants define the offsets within a FlashBuffer data * type for each kind of data. Note that the read data offset is not the * same as the write data because the SPI driver is designed to allow full * duplex transfers such that the number of bytes received is the number * sent and received. */ #define DATA_OFFSET 4 /* Start of Data for Read/Write */ #define DUMMY_SIZE 1 /* Number of dummy bytes for fast, dual and quad reads */ /* * The following constants specify the page size, sector size, and number of * pages and sectors for the FLASH. The page size specifies a max number of * bytes that can be written to the FLASH with a single transfer. */ #define SECTOR_SIZE 0x10 #define NUM_SECTORS 0x02 /* * Flash address to which data is to be written. */ #define TEST_ADDRESS 0x003D0D00 #define UNIQUE_VALUE 0x05 /* * The following constants specify the max amount of data and the size of the * the buffer required to hold the data and overhead to transfer the data to * and from the FLASH. */ #define MAX_DATA SECTOR_SIZE * NUM_SECTORS /* * The following constant defines the slave select signal that is used to * to select the FLASH device on the SPI bus, this signal is typically * connected to the chip select of the device */ #define FLASH_SPI_SELECT_1 0x01 #define FLASH_SPI_SELECT_0 0x00 /**************************** Type Definitions *******************************/ /***************** Macros (Inline Functions) Definitions *********************/ /************************** Function Prototypes ******************************/ int FlashErase(XIsf *InstancePtr, u32 Address, u32 ByteCount); int FlashWrite(XIsf *InstancePtr, u32 Address, u32 ByteCount, u8 Command); int FlashRead(XIsf *InstancePtr, u32 Address, u32 ByteCount, u8 Command); int WriteEnable(XIsf *InstancePtr); int SpiFlashPolledExample(XSpi *SpiInstancePtr, u16 SpiDeviceId); /************************** Variable Definitions *****************************/ /* * The instances to support the device drivers are global such that they * are initialized to zero each time the program runs. They could be local * but should at least be static so they are zeroed. */ static XSpi SpiInstance; static XIsf Isf; /* * The following variables are used to read and write to the eeprom and they * are global to avoid having large buffers on the stack */ u8 ReadBuffer[MAX_DATA + DATA_OFFSET + DUMMY_SIZE]; u8 WriteBuffer[MAX_DATA + DATA_OFFSET]; u8 IsfWriteBuffer[XISF_CMD_SEND_EXTRA_BYTES + 1]; /*****************************************************************************/ /** * * Main function to call the SPI Flash example. * * @param None * * @return XST_SUCCESS if successful, otherwise XST_FAILURE. * * @note None * ******************************************************************************/ int main(void) { int Status = XST_FAILURE; xil_printf("SPI FLASH Polled Example Test \r\n"); /* * Run the Spi Interrupt example. */ Status = SpiFlashPolledExample(&SpiInstance,SPI_DEVICE_ID); if (Status != XST_SUCCESS) { xil_printf("Status: %d \r\n", Status); xil_printf("SPI FLASH Polled Example Test Failed\r\n"); return XST_FAILURE; } xil_printf("Successfully ran SPI FLASH Polled Example Test\r\n"); return XST_SUCCESS; } /***************************************************************************** * * The purpose of this function is to illustrate how to use the XSpiPs * device driver in interrupt mode. This function writes and reads data * from a serial FLASH. * * @param None. * * @return XST_SUCCESS if successful else XST_FAILURE. * * @note * * This function calls other functions which contain loops that may be infinite * if interrupts are not working such that it may not return. If the device * slave select is not correct and the device is not responding on bus it will * read a status of 0xFF for the status register as the bus is pulled up. * *****************************************************************************/ void FlashWriteSPI(XIsf *InstancePtr, u32 Address, u32 ByteCount, u8 Command); int SpiFlashPolledExample(XSpi *SpiInstancePtr, u16 SpiDeviceId) { xil_printf("Inside SPI Flash Polled Example\r\n"); u8 *BufferPtr; u8 UniqueValue; u32 Count; XSpi_Config *ConfigPtr; /* Pointer to Configuration ROM data */ u32 TempAddress; u32 MaxSize = MAX_DATA; u32 ChipSelect = FLASH_SPI_SELECT_1; if (XGetPlatform_Info() == XPLAT_MICROBLAZE) { MaxSize = 10 * 1; ChipSelect = FLASH_SPI_SELECT_0; /* Device is on CS 0 */ xil_printf("If 1 \r\n"); } /* * Lookup the device configuration in the temporary CROM table. Use this * configuration info down below when initializing this component. */ ConfigPtr = XSpi_LookupConfig(SpiDeviceId); if (ConfigPtr == NULL) { xil_printf("If 2 \r\n"); return XST_DEVICE_NOT_FOUND; } XSpi_CfgInitialize(SpiInstancePtr, ConfigPtr, ConfigPtr->BaseAddress); /* Initialize the XILISF Library */ XIsf_Initialize(&Isf, SpiInstancePtr, ChipSelect, IsfWriteBuffer); memset(WriteBuffer, 0x00, sizeof(WriteBuffer)); memset(ReadBuffer, 0x00, sizeof(ReadBuffer)); /* Unprotect Sectors */ FlashWrite(&Isf, 0, 0, XISF_WRITE_STATUS_REG); FlashErase(&Isf, TEST_ADDRESS, MaxSize); /* * Initialize the write buffer for a pattern to write to the FLASH * and the read buffer to zero so it can be verified after the read, the * test value that is added to the unique value allows the value to be * changed in a debug environment to guarantee */ TempAddress = TEST_ADDRESS; for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MaxSize; Count++, UniqueValue++, TempAddress++) { WriteBuffer[0] = (u8)(UniqueValue); FlashWrite(&Isf, TempAddress, 1, XISF_WRITE); xil_printf("Flash Write to %d, value is %d \r\n", TempAddress, WriteBuffer[0]); } /* * Read the contents of the FLASH from TEST_ADDRESS, using Normal Read * command */ FlashRead(&Isf, TEST_ADDRESS, MaxSize, XISF_READ); /* * Setup a pointer to the start of the data that was read into the read * buffer and verify the data read is the data that was written */ BufferPtr = &ReadBuffer[DATA_OFFSET]; for (UniqueValue = UNIQUE_VALUE, Count = 0; Count < MaxSize; Count++, UniqueValue++) { xil_printf("Flash Read is %d \r\n", BufferPtr[Count]); if (BufferPtr[Count] != (u8)(UniqueValue)) { //return XST_FAILURE; } } return XST_SUCCESS; } I edited only main and SpiFlashPolledExample function, all other functions are untouched. Now when I run it , I get (consoleOutput.png). I fear that flash is not being written at the first place. What am I missing here? Kindly help @D@n Any other working projects/examples would be of great help.
  20. I'm having some difficulty setting up SPI to receive data from the the PmodALS. I'm using the 328PB board with the initialization and receive code below: void SPI_MasterInit(void) { DDRC |= (1<<PORTC1); //set SCK (PC1) to output. DDRC &= ~(1<<PORTC0); //Set MISO (PC0) as input. DDRE |= (1<<PORTE3) | (1<<PORTE2); // Set MOSI (PE3) to output and SS (PE2) to output // Enable SPI, Master SPCR1 |= (1<<SPE1) | (1<<MSTR1) | (1<<SPR10); //Set to /16 prescaler so peripheral PmodALS operates at 1MHZ } // Sends a 16bit word (command + data) to DAC over SPI int SPI_receiver_for_ALS(void) { PORTE &= ~(1<<PORTE2); // Pull Slave_Select (PORTE2) low to tell it to start reporting data = (SPDR1 << 8); //Take first 8 bits of information while(!(SPSR1 & (1<<SPIF1))); // Wait for transmission complete data |= (SPDR1 >> 8); //Take last 8 bits of information while(!(SPSR1 & (1<<SPIF1))); // Wait for transmission complete PORTE |= (1<<PORTE2); // Pull Slave_Select (PORTE2) high to tell it to stop reporting return data; } The program gets stuck in the wait for transfer loop, and outputs no data values. When I disable it, I receive values of zero. I've scoured the datasheets and I'm not sure what I missed. Does anybody have an insights to what I need to do? (I attached the rest of my code as reference) Thanks a lot! main.c uart.c uart.h PmodALS datasheet.pdf
  21. I would like to use 6 Pmod ISNS20 current sensors in a prototype application, and I would like to use an off-the-shelf interface board to connect to all the sensors. However, the Digilent Pmod HAT adapter (for Raspberry Pi) can only be used to connect to two SPI devices, so can't be used. Does anyone know of an interface board that I can use to connect to 6 SPI devices? I haven't selected a controller yet, so Arduino/Pi/etc boards would be Ok. I know that I can make an I/F board using GPIO pins to drive the various slave selects, and write software to handle this, but I would much prefer an off-the-shelf solution. Thanks.
  22. Hello I am creating a verilog module on the basys 3 board to interface with the Pmod DA3. I have tried running the module with the DA3 connected and wasn't getting any voltage reading. I have my sclk speed at 25Mhz. Below is my current code and screenshots of my test bench and the pmod outputs on an oscilloscope. Any help is appreciated. `timescale 1ns / 1ps module sclk( input clock, input reset, output sclk ); reg[24:0] count = 0; reg sclk = 0; always @ (posedge clock or posedge reset) begin if (reset ==1'b1)begin count <= 0; sclk <= 0; end else begin count <= count + 1; if(count == 1) begin sclk <= ~sclk; count <= 0; end end end endmodule __ `timescale 1ns / 1ps module spi0( input clock, input reset, input send, output sclk0, output reg cs, output reg ldac, output reg din ); reg[15:0] data [3:0]; reg[15:0] count; reg [1:0] sel; sclk sclk_inst ( .clock(clock), .reset(reset), .sclk(sclk0) ); initial begin data[0] = 16'b0101111000010101; data[1] = 16'b1000011111100001; count = 16'd16; cs = 1; sel = 0; end always @ (negedge sclk0 & send == 1)begin if (send == 1)begin if ( count > 0)begin cs = 0; ldac = 0; end if (count == 0)begin cs = 1; ldac = 1; count = 16'd16; end din = data[sel][count-1]; count = count - 1; end end endmodule __ `timescale 1ns / 1ps module spi0_testbench(); reg clock = 0; reg reset = 0; reg send = 0; reg [50:0]counter = 0; reg [16:0] i; wire sclk0; wire cs; wire ldac; wire din; wire[15:0] count; spi0 UUT(clock, reset, send, sclk0, cs, ldac, din); always @ (*)begin #10 if (i >= 127 & i < 129)begin send = 0; end if (i < 127 | i >= 129) begin send = 1; end if (i < 127)begin end end initial begin for (i = 0; i < 1000; i = i + 1)begin clock = ~clock; counter = counter + 1; #1; end end endmodule Green: SCLK Yellow: DIN Blue: CS Pink: LDAC
  23. Hello, I tried posting this on the Xilinx forums but got no response. These forums look more active and friendly so hopefully somebody can help me. I am really stuck. I am trying to follow along with the "How To Store Your SDK Project in SPI Flash" tutorial (https://reference.digilentinc.com/learn/programmable-logic/tutorials/htsspisf/start), but I cannot get it to work. I am using an Artix-7 35T Arty FPGA Evaluation Kit. I am running Vivado v2017.2 (64-bit) and SDK v2017.2 on a Windows 10 machine. First, I created a simple "Hello World" program by following the steps in the "Arty - Getting Started With Microblaze" tutorial ( https://reference.digilentinc.com/learn/programmable-logic/tutorials/arty-getting-started-with-microblaze/start). The only deviation from the instructions that I made was that after adding the MIG to the board, I added an AXI Quad SPI, with enabled port SPI_0, and then ran "Run Connection Automation". When I ran my C program on the Arty board it worked fine, and printed "Hello World" to my PuTTY terminal. I've attached my board file as both .bd and .png. Second, I tried store this "Hello World" program to the Arty's SPI Flash using the "How To Store Your SKD Project in SPI Flash" tutorial. But, it did not work. I'll walk you through what I did because there are a few things that I am confused about. Unless otherwise noted I followed the instructions exactly. Before step 0: I don't know what the QSpi mode jumper setting is referring to, so I didn't do anything. Step 1.3: I compressed my bitstream so I left FLASH_IMAGE_BASEADDR as 0xF8000000, like I found it. Steps 2.1 and 2.2: I used my "Hello World" app that I created by following the "Arty - Getting Started with Microblaze" tutorial. I couldn't place the sections into mig_7series_0 because that wasn't an option, so instead I used mig_7series_0_memaddr. Step 4.1: I used offset 0xF8000000 because that is what I used in Step 1.3. One other thing: the test says to use Arty flash type mt25ql128-spi-x1_x2_x4 (which I do), but the image of the "Program Flash Memory" window shows them using Arty flash type n25ql128-spi-x1_x2_x4. Step 5: it doesn't work. Does anyone have any suggestions? Is the SPI Flash some sort of external hardware that I need to plug into the Arty? Thanks in advance. design_1.bd
  24. Arduino is the SPI Master and therefore provides the clock, SPICLK through a PMOD. How do I receive the clock in a good way on the FPGA? Vivado does not approve of checking rising_edge(SPICLK) so I though I'd put a clock buffer or something in between (not that I know why or what they do but it sounds like a good idea). At some point Vivado told me to add "set_property CLOCK_DEDICATED_ROUTE FALSE [get_nets {SPICLK_IBUF}]" to the constraints file, but I still got warnings and it didn't recommend I proceed. If I have the top level SPICLK connected to an IBUF_IBUFDISABLE with the disable line connected to the slave select (SS) line, I get this warning: [DRC 23-20] Rule violation (CKLD-2) Clock Net has IO Driver, not a Clock Buf, and/or non-Clock loads - Clock net spi_buf is directly driven by an IO rather than a Clock Buffer or may be an IO driving a mix of Clock Buffer and non-Clock loads. This connectivity should be reviewed and corrected as appropriate. Driver(s): IBUF_IBUFDISABLE_inst/O If I have the top level SPICLK connected to an IBUF_IBUFDISABLE and that into a BUFGCE, with the disable line connected to the slave select (SS) line and the inverse of SS into the CE, I get this warning: [Place 30-574] Poor placement for routing between an IO pin and BUFG. This is normally an ERROR but the CLOCK_DEDICATED_ROUTE constraint is set to FALSE allowing your design to continue. The use of this override is highly discouraged as it may lead to very poor timing results. It is recommended that this error condition be corrected in the design. IBUF_IBUFDISABLE_inst (IBUF_IBUFDISABLE.O) is locked to IOB_X0Y25 and BUFGCE_inst (BUFGCTRL.I0) is provisionally placed by clockplacer on BUFGCTRL_X0Y1 Roughly the same warning was issued with just the BUFGCE. I know there are other ways of polling the input clock from the arduino and treating it as normal signal but I want to do it the "proper" way.