I have been using the Waveforms Protocol panel to successfully send SPI messages using the Digital DIscovery device. For now, I Execute two long sets of bytes (an example of the second set of bytes is shown in the pic below).
In playing with the scripting, I'm trying to do the same thing but by sending many sets of three-byte-blocks instead of just that one long DQ0 line above. The simple script is shown below. FWIW, the content in DQ0 above is the second set of Write's in the script after the wait statement. Anyway, I don't get the same result when I execute/Run this simple script. Any assistance with the solution?
clear() // clear the output window
print ("Starting script...");
print("Lowering chip select.");
Protocol.SPI.Start();
print("Peforming the init sequence from the NewHaven user manual.");
Protocol.SPI.Write (8, 0xF8, 0x50, 0x40); // Function set (extended command set)
Protocol.SPI.Write (8, 0xF8, 0x80, 0xE0); // Function selection A
Protocol.SPI.Write (8, 0xFA, 0x00, 0x00); // Disable internal VDD regulator (2.8V I/O) <--3.3VIO
Protocol.SPI.Write (8, 0xF8, 0x10, 0x40); // Function set (fundamental command set)
Protocol.SPI.Write (8, 0xF8, 0xF0, 0x00); // Display on, cursor on, blink on
Protocol.SPI.Write (8, 0xF8, 0x50, 0x40); // Function set (extended command set)
Protocol.SPI.Write (8, 0xF8, 0x90, 0xE0); // OLED command set enabled
Protocol.SPI.Write (8, 0xF8, 0xA0, 0xB0); // Set display clock divide ratio/oscillator frequency
Protocol.SPI.Write (8, 0xF8, 0x00, 0xE0); // Set display clock divide ratio/oscillator frequency
Protocol.SPI.Write (8, 0xF8, 0x10, 0xE0); // OLED command set disabled
Protocol.SPI.Write (8, 0xF8, 0x90, 0x00); // Extended function set (4-lines)
Protocol.SPI.Write (8, 0xF8, 0x60, 0x00); // COM SEG direction
Protocol.SPI.Write (8, 0xF8, 0x40, 0xE0); // Function selection B
Protocol.SPI.Write (8, 0xFA, 0x00, 0x00); // ROM CGRAM selection
Protocol.SPI.Write (8, 0xF8, 0x50, 0x40); // Function set (extended command set)
Protocol.SPI.Write (8, 0xF8, 0x90, 0xE0); // OLED command set enabled
Protocol.SPI.Write (8, 0xF8, 0x50, 0xB0); // Set SEG pins hardware configuration
Protocol.SPI.Write (8, 0xF8, 0x00, 0x80); // Set SEG pins hardware configuration
Protocol.SPI.Write (8, 0xF8, 0x30, 0xB0); // Function selection C
Protocol.SPI.Write (8, 0xF8, 0x00, 0x00); // Function selection C
Protocol.SPI.Write (8, 0xF8, 0x80, 0x10); // Set contrast control
Protocol.SPI.Write (8, 0xF8, 0xF0, 0xE0); // Set contrast control
Protocol.SPI.Write (8, 0xF8, 0x90, 0xB0); // Set phase length
Protocol.SPI.Write (8, 0xF8, 0x80, 0xF0); // Set phase length
Protocol.SPI.Write (8, 0xF8, 0xD0, 0xB0); // Set VCOMH deselect level
Protocol.SPI.Write (8, 0xF8, 0x00, 0x20); // Set VCOMH deselect level
Protocol.SPI.Write (8, 0xF8, 0x10, 0xE0); // OLED command set disabled
Protocol.SPI.Write (8, 0xF8, 0x10, 0x40); // Function set (fundamental command set)
Protocol.SPI.Write (8, 0xF8, 0x80, 0x00); // Clear display
Protocol.SPI.Write (8, 0xF8, 0x00, 0x10); // Set DDRAM address to 0x00
Protocol.SPI.Write (8, 0xF8, 0x30, 0x00); // Display ON
print(" Init sequence Complete.");
print("Delaying 100ms.");
wait(0.10) // Wait 100ms
print(" Delay complete.");
print("Clearing display and setting cursor at top-left-most position.");
Protocol.SPI.Write (8, 0xF8, 0x80, 0x00); //Clear display
Protocol.SPI.Write (8, 0x40, 0x00); //Return home
// write 10 chars to display
print("Writing characters to display.");
Protocol.SPI.Write (8, 0xF8, 0x80, 0x00); // Clear display
Protocol.SPI.Write (8, 0xF8, 0x40, 0x00); // Return home
Protocol.SPI.Write (8, 0xF8, 0x00, 0x50); // Set DDRAM address
Protocol.SPI.Write (8, 0xFA, 0x00, 0x40); // Write character 0x20
Protocol.SPI.Write (8, 0xFA, 0x00, 0xA0); // Write character 0x50
Protocol.SPI.Write (8, 0xFA, 0x00, 0xA0); // Write character 0x50
Protocol.SPI.Write (8, 0xFA, 0xF0, 0x20); // Write character 0x4F
Protocol.SPI.Write (8, 0xFA, 0x70, 0x20); // Write character 0x4E
Protocol.SPI.Write (8, 0xFA, 0xF0, 0x20); // Write character 0x4F
Protocol.SPI.Write (8, 0xFA, 0x60, 0xA0); // Write character 0x56
Protocol.SPI.Write (8, 0xFA, 0x80, 0x20); // Write character 0x41
Protocol.SPI.Write (8, 0xFA, 0x00, 0x40); // Write character 0x20
Protocol.SPI.Write (8, 0xFA, 0xC0, 0xA0); // Write character 0x53
Protocol.SPI.Write (8, 0xFA, 0xF0, 0x20); // Write character 0x4F
Protocol.SPI.Write (8, 0xFA, 0x30, 0x20); // Write character 0x4C
Protocol.SPI.Write (8, 0xFA, 0xA0, 0xA0); // Write character 0x55
Protocol.SPI.Write (8, 0xFA, 0x20, 0xA0); // Write character 0x54
Protocol.SPI.Write (8, 0xFA, 0x90, 0x20); // Write character 0x49
Protocol.SPI.Write (8, 0xFA, 0xF0, 0x20); // Write character 0x4F
Protocol.SPI.Write (8, 0xFA, 0x70, 0x20); // Write character 0x4E
Protocol.SPI.Write (8, 0xFA, 0xC0, 0xA0); // Write character 0x53
Protocol.SPI.Write (8, 0xFA, 0x00, 0x40); // Write character 0x20
Protocol.SPI.Write (8, 0xFA, 0x00, 0x40); // Write character 0x20
print("Completed writing characters to display.");
print("Raising chip select.");
Protocol.SPI.Stop();
print ("Finished!");
Question
engrpetero
I have been using the Waveforms Protocol panel to successfully send SPI messages using the Digital DIscovery device. For now, I Execute two long sets of bytes (an example of the second set of bytes is shown in the pic below).
In playing with the scripting, I'm trying to do the same thing but by sending many sets of three-byte-blocks instead of just that one long DQ0 line above. The simple script is shown below. FWIW, the content in DQ0 above is the second set of Write's in the script after the wait statement. Anyway, I don't get the same result when I execute/Run this simple script. Any assistance with the solution?
clear() // clear the output window print ("Starting script..."); print("Lowering chip select."); Protocol.SPI.Start(); print("Peforming the init sequence from the NewHaven user manual."); Protocol.SPI.Write (8, 0xF8, 0x50, 0x40); // Function set (extended command set) Protocol.SPI.Write (8, 0xF8, 0x80, 0xE0); // Function selection A Protocol.SPI.Write (8, 0xFA, 0x00, 0x00); // Disable internal VDD regulator (2.8V I/O) <--3.3VIO Protocol.SPI.Write (8, 0xF8, 0x10, 0x40); // Function set (fundamental command set) Protocol.SPI.Write (8, 0xF8, 0xF0, 0x00); // Display on, cursor on, blink on Protocol.SPI.Write (8, 0xF8, 0x50, 0x40); // Function set (extended command set) Protocol.SPI.Write (8, 0xF8, 0x90, 0xE0); // OLED command set enabled Protocol.SPI.Write (8, 0xF8, 0xA0, 0xB0); // Set display clock divide ratio/oscillator frequency Protocol.SPI.Write (8, 0xF8, 0x00, 0xE0); // Set display clock divide ratio/oscillator frequency Protocol.SPI.Write (8, 0xF8, 0x10, 0xE0); // OLED command set disabled Protocol.SPI.Write (8, 0xF8, 0x90, 0x00); // Extended function set (4-lines) Protocol.SPI.Write (8, 0xF8, 0x60, 0x00); // COM SEG direction Protocol.SPI.Write (8, 0xF8, 0x40, 0xE0); // Function selection B Protocol.SPI.Write (8, 0xFA, 0x00, 0x00); // ROM CGRAM selection Protocol.SPI.Write (8, 0xF8, 0x50, 0x40); // Function set (extended command set) Protocol.SPI.Write (8, 0xF8, 0x90, 0xE0); // OLED command set enabled Protocol.SPI.Write (8, 0xF8, 0x50, 0xB0); // Set SEG pins hardware configuration Protocol.SPI.Write (8, 0xF8, 0x00, 0x80); // Set SEG pins hardware configuration Protocol.SPI.Write (8, 0xF8, 0x30, 0xB0); // Function selection C Protocol.SPI.Write (8, 0xF8, 0x00, 0x00); // Function selection C Protocol.SPI.Write (8, 0xF8, 0x80, 0x10); // Set contrast control Protocol.SPI.Write (8, 0xF8, 0xF0, 0xE0); // Set contrast control Protocol.SPI.Write (8, 0xF8, 0x90, 0xB0); // Set phase length Protocol.SPI.Write (8, 0xF8, 0x80, 0xF0); // Set phase length Protocol.SPI.Write (8, 0xF8, 0xD0, 0xB0); // Set VCOMH deselect level Protocol.SPI.Write (8, 0xF8, 0x00, 0x20); // Set VCOMH deselect level Protocol.SPI.Write (8, 0xF8, 0x10, 0xE0); // OLED command set disabled Protocol.SPI.Write (8, 0xF8, 0x10, 0x40); // Function set (fundamental command set) Protocol.SPI.Write (8, 0xF8, 0x80, 0x00); // Clear display Protocol.SPI.Write (8, 0xF8, 0x00, 0x10); // Set DDRAM address to 0x00 Protocol.SPI.Write (8, 0xF8, 0x30, 0x00); // Display ON print(" Init sequence Complete."); print("Delaying 100ms."); wait(0.10) // Wait 100ms print(" Delay complete."); print("Clearing display and setting cursor at top-left-most position."); Protocol.SPI.Write (8, 0xF8, 0x80, 0x00); //Clear display Protocol.SPI.Write (8, 0x40, 0x00); //Return home // write 10 chars to display print("Writing characters to display."); Protocol.SPI.Write (8, 0xF8, 0x80, 0x00); // Clear display Protocol.SPI.Write (8, 0xF8, 0x40, 0x00); // Return home Protocol.SPI.Write (8, 0xF8, 0x00, 0x50); // Set DDRAM address Protocol.SPI.Write (8, 0xFA, 0x00, 0x40); // Write character 0x20 Protocol.SPI.Write (8, 0xFA, 0x00, 0xA0); // Write character 0x50 Protocol.SPI.Write (8, 0xFA, 0x00, 0xA0); // Write character 0x50 Protocol.SPI.Write (8, 0xFA, 0xF0, 0x20); // Write character 0x4F Protocol.SPI.Write (8, 0xFA, 0x70, 0x20); // Write character 0x4E Protocol.SPI.Write (8, 0xFA, 0xF0, 0x20); // Write character 0x4F Protocol.SPI.Write (8, 0xFA, 0x60, 0xA0); // Write character 0x56 Protocol.SPI.Write (8, 0xFA, 0x80, 0x20); // Write character 0x41 Protocol.SPI.Write (8, 0xFA, 0x00, 0x40); // Write character 0x20 Protocol.SPI.Write (8, 0xFA, 0xC0, 0xA0); // Write character 0x53 Protocol.SPI.Write (8, 0xFA, 0xF0, 0x20); // Write character 0x4F Protocol.SPI.Write (8, 0xFA, 0x30, 0x20); // Write character 0x4C Protocol.SPI.Write (8, 0xFA, 0xA0, 0xA0); // Write character 0x55 Protocol.SPI.Write (8, 0xFA, 0x20, 0xA0); // Write character 0x54 Protocol.SPI.Write (8, 0xFA, 0x90, 0x20); // Write character 0x49 Protocol.SPI.Write (8, 0xFA, 0xF0, 0x20); // Write character 0x4F Protocol.SPI.Write (8, 0xFA, 0x70, 0x20); // Write character 0x4E Protocol.SPI.Write (8, 0xFA, 0xC0, 0xA0); // Write character 0x53 Protocol.SPI.Write (8, 0xFA, 0x00, 0x40); // Write character 0x20 Protocol.SPI.Write (8, 0xFA, 0x00, 0x40); // Write character 0x20 print("Completed writing characters to display."); print("Raising chip select."); Protocol.SPI.Stop(); print ("Finished!");
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now