Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by Stunts1337

  1. #define GPIO 11 //random digital pin
    void setup() {                
      pinMode(GPIO, OUTPUT);     
    void loop() {
      //get char from serial monitor
      //convert char into an array with 8 value (lets say, tranData[] - add to setup)
      for (int i = 0; i < 8; i++) {
        if (tranData[i] == 1) { digitalWrite(GPIO, HIGH); }
        else { digitalWrite(GPIO, LOW); } 

    In this case, your array should look something like an 8-bit binary value. 


    If the data bit in the i-th position of the array is a 1, GPIO pin will go high (3.3v), else it will go low (0v).


    Use the voltages from the IO pin to transmit a high or low signal to your other MSP.  Now you need to probably add a delay in between loop iterations so keep that in mind - remember your transmitting speed.  You may also want to send a high signal to indicate data is about to be sent to your receiving MSP.


    On the transmitting side, receive the transmitted signal and feed it into an LED and into a digital input pin. When you get a high signal (the indicator signal), go into a loop that loops at your transmitting speed and read the next 8 bits that are transmitted, and save them into a variable.


    For example, you transmit once every 10ms -> send a high and delay for 10ms, then send your 8-bit value 1 bit at a time every 10ms.  When you receive the initial high signal, start reading the state of the receiving input pin once every 10ms (starting 10ms after the indicator signal), do this in a loop 8 times to save all 8 bits.  Now you have all 8 bits saved, and you can translate that into the corresponding ascii value and print it to the serial monitor.


    Fair warning: I am by no means a pro at this, your project just seemed a bit interesting to me, and this is how i would approach it (with what little experience I have). - there could very well be a better way.

  2. Hi, I am trying to change the SPI clock phase for my project.  I am wondering if it is possible in energia.  Below is the corresponding data bits from the family guide that I have found:




    I am trying to change the clock phase (bit 7) from the default 0 to 1, because that is what is required for the slave device (an ADF4002).


    All I could find in energia were the following 3 functions to change other aspects of the SPI communication:


    On that note, does anyone know what the setDataMode function controls?
    Thanks for any help!
  3. Hi everyone, I first want to say this isn't a huge priority, but if you have time to look over my code and point out any obvious errors I would appreciate it.


    The code is based off of the getWeather sketch provided by Energia, it searches a server api that I control for 4 integer values: 3 that are used to program a digital potentiometer and one that controls 3 different GPIO pins which ultimately controls some relays.  The basic idea is the msp430 will test the circuit I select by turning on the correct relay, and the digital potentiometer allows for an user adjustable gain in the circuit being tested.


    The problem I am having is the cc3200 launchpad frequently becomes unable to connect to server when I run the code below.  The msp430 gets into a state where it keeps trying to connect to server but is never able to.  It typically takes the data from the server about 10 times before becoming unable to connect, and seems to fail more when the data in the server has changed. The code searches the server every 5 seconds.


    If anyone has any suggestions to potentially help the problem I am having with my code, any feedback would be appreciated.


    #include <SPI.h>
    #include <WiFi.h>

    // network login info
    char ssid[] = "(my SSID)";
    char password[] = "(my Pass)";

    IPAddress hostIp(184,106,153,149); //IP address for ThingSpeak
    WiFiClient client;

    const unsigned long requestInterval = 5000; // delay between requests (5 sec)
    unsigned long lastAttemptTime = 0; // variable to hold the last time you connected to the server
    String currentLine = ""; // string to hold the text from server
    String circuitString = ""; // string to hold circuit selection
    boolean readingCircuit = false; // if you're currently reading the circuit selection
    String invertingString = ""; // string to hold inverting resistance selection
    boolean readingInverting = false; // if you're currently reading the inverting resistance selection
    String nonInvertingString = ""; // string to hold non-inverting resistance selection
    boolean readingNonInverting = false; // if you're currently reading the non-inverting resistance selection
    String weightedString = ""; // string to hold weighted summer resistance selection
    boolean readingWeighted = false; // if you're currently reading the weighted summer resistance selection
    int circuit = 1; // holds circuit selection (inverting = defalt)
    int inverting = 33; // holds inverting resistance selection (33 = min value)
    int nonInverting = 4; // holds non-inverting resistance selection (4 = min value)
    int weighted = 17; // holds weighted summer resistance selection (17 = min value)
    int temp = 0; // temporary integer value used in string to int function
    boolean flag = false; // used to update values (I/O pins and digital pot)

    void setup() {
    currentLine.reserve(100); // reserve space for strings

    Serial.begin(115200); // set baud rate for serial communication

    pinMode (8, OUTPUT);
    pinMode (9, OUTPUT);
    pinMode (10, OUTPUT);

    pinMode (18, OUTPUT); // SS pin for SPI data transfer
    SPI.begin(); // SPI for digital potentiometer programming
    digitalPotWrite(0,inverting); // initalize digital potentiometer values to base values (gain of ~1.2 V/V, or ~6V output)
    delay(10); //short delay
    delay(10); //short delay

    Serial.print("Attempting to connect to Network named: ");
    WiFi.begin(ssid, password);
    while ( WiFi.status() != WL_CONNECTED) {
    Serial.print("."); // print dots while we wait to connect
    Serial.println("\nYou're connected to the network");
    Serial.println("Waiting for an ip address");
    while (WiFi.localIP() == INADDR_NONE) {
    Serial.print("."); // print dots while we wait for an ip addresss
    Serial.println("\nIP Address obtained");

    void loop() {
    if (client.available()) {
    char inChar = client.read(); // read incoming bytes:
    currentLine += inChar; // add incoming byte to end of line:
    if (inChar == '\n') { // if a newline is found, clear the line:
    currentLine = "";

    if ( currentLine.endsWith("<field1>")) {
    readingCircuit = true; // Circuit selection data is beginning, clear circuit string
    circuitString = "";

    if (readingCircuit) {
    if (inChar != 'f') { // if you see 'f', you're done reading circuit selection
    circuitString += inChar;
    else {
    readingCircuit = false; //termination character was found
    Serial.print("- Circuit Selection: ");
    circuit = getInt(circuitString);
    Serial.println(" (1 = non-inverting, 2 = inverting, 3 = weighted summer)");

    if ( currentLine.endsWith("<field2>")) {
    readingInverting = true; // Circuit selection data is beginning, clear inverting string
    invertingString = "";

    if (readingInverting) {
    if (inChar != 'f') { // if you see 'f', you're done reading inverting selection
    invertingString += inChar;
    else {
    readingInverting = false; //termination character was found
    Serial.print("- Inverting Resistance Selection: ");
    inverting = getInt(invertingString);

    if ( currentLine.endsWith("<field3>")) {
    readingNonInverting = true; // Circuit selection data is beginning, clear non-inverting string
    nonInvertingString = "";

    if (readingNonInverting) {
    if (inChar != 'f') { // if you see 'f', you're done reading non-inverting selection
    nonInvertingString += inChar;
    else {
    readingNonInverting = false; //termination character was found
    Serial.print("- Non-Inverting Resistance Selection: ");
    nonInverting = getInt(nonInvertingString);

    if ( currentLine.endsWith("<field4>")) {
    readingWeighted = true; // Circuit selection data is beginning, clear weighted summer string
    weightedString = "";

    if (readingWeighted) {
    if (inChar != 'f') { // if you see 'f', you're done reading weighted summer selection
    weightedString += inChar;
    else {
    readingWeighted = false; //termination character was found
    Serial.print("- Weighted Summer Resistance Selection: ");
    weighted = getInt(weightedString);
    flag = true; // Done reading data, so set flag
    if (flag) { //done reading server data, now update digital potentiometer and GPIO pins
    Serial.println("Done reading values!");
    digitalPotWrite(0,nonInverting); //write to resistor 1
    digitalPotWrite(1,weighted); //write to resistor 2
    digitalPotWrite(2,inverting); //write to resistor 3
    if (circuit == 2) { // Non-Inverting selected
    Serial.println("Non-Inverting resistance updated!");
    else if (circuit == 1) { // Inverting selected
    Serial.println("Inverting resistance updated!");
    else { // Weighted summer selected, default case
    Serial.println("Weighted summer resistance updated!");
    flag = false; //reset flag
    else if (millis() - lastAttemptTime > requestInterval) {

    void connectToServer(){
    Serial.println("connecting to server...");
    if (client.connect(hostIp, 80)) {
    Serial.println("Connected! Reading web server data...");
    client.println("GET /channels/(my channel id)/feed/last.xml"); // make HTTP GET request to ThingSpeak
    client.print("HOST: http://api.thingspeak.com\n"); // declare correct server
    client.println("Connection: close"); // close connection
    lastAttemptTime = millis(); // timestamp for this connection

    void printWifiStatus() {
    Serial.print("SSID: ");
    Serial.println(WiFi.SSID()); //print SSID
    IPAddress ip = WiFi.localIP();
    Serial.print("IP Address: ");
    Serial.println(ip); //print IP address

    int digitalPotWrite(int address, int value) {
    Serial.println("Writing resistance values");
    digitalWrite(18,LOW); // take the SS pin low to select the digital pot
    SPI.transfer(address); // send in the address (resistor selection)
    SPI.transfer(value); // send in the value (resistor value)
    digitalWrite(18,HIGH); // take the SS pin high to de-select the digital pot

    int getInt(String input){ //converts string to integer
    int i = 1;
    while(input[i] != '<'){
    input = input.substring(1,i);
    char carray[20];
    input.toCharArray(carray, sizeof(carray));
    temp = atoi(carray); //atoi() converts an array of char to a string
    return temp;

  4. You can include SPI.h for CC3200 apps. That line is in the examples because SPI.h isn't strictly necessary to enable WiFi support like it is on CC3100 examples for the MSP430 and Tiva. (The CC3200 WiFi examples are an exact copy of the CC3100 WiFi examples FYI).

    Thank you that is good to know.  I took a break to eat and relax for a bit, turns out I was very dumb in forgetting to assign the pinmode as output for the CS pin.  Sometimes you just make those dumb mistakes that cost you lots of annoyance.  


    Not in the clear quite yet, but I do have a program working which reads the data from the server, then disconnects from WiFi and enters a loop using the digital potentiometer, so it looks to be a promising start.


    Thanks again for the clarification.

  5. Could someone give me more information on why we cannot include SPI for the cc3200 (as it says at the beginning of every wifi sketch)

    #ifndef __CC3200R1M1RGC__
    // Do not include SPI for CC3200 LaunchPad
    #include <SPI.h>

    I would really like to send a http get request to a server host and program a digital potentiometer based on the values read from the server, but the digital potentiometer uses SPI for data transfer.  As of right now I have taken the values from the server and filtered out the data to the few variables I need to use, and that loops every 10 seconds.  At this point I would like to program the digital potentiometer based on the values read from the server, but it doesn't seem to work.  I do also have the digital potentiometer working on its own if it is not in a wifi sketch.


    Is there anyway to work around this and accomplish this goal, or could anyone link me to some more information on this subject?




    Edit: getting closer to having this work, but if you have anymore insight around this subject feel free to post it, I would like to know everything and anything regarding this topic.

  6. Hi I was wondering if there is support for the SPI(1) pins that are on the msp430f5529 pin mapping page. (http://energia.nu/Guide_MSP430F5529LaunchPad.html)


    I am currently using a msp430f5529 and a CC3000 boosterpack.


    I am trying to program a digital potentiometer while also using the cc3000 boosterpack, my code works off of the getweather code to get data from a server with the cc3000, once it has that data I want to program the digital potentiometer based on the value of that data.


    I have code working for both the reading data from the server, and also for programming the digital potentiometer which both work on their own, however when I try to combine the two, the digital potentiometer is not getting programmed.  I believe this error is due to attempting to use SPI to program the digital potentiometer while also using the cc3000 boosterpack, so I am currently trying to get my digital potentiometer working with the SPI(1) pins in hopes that using them will solve my problem and not interfere with the cc3000.


    Or, if anyone has a suggestion on how to use both the cc3000 and the digital potentiometer with the regular SPI pins, that would be appreciated also.




    Also, while im here, the device seems to fail quite often it will just stop reading values from the server after a few minutes, if anyone knows a reason for why that might be happening let me know please.

  7. Hi guys, I am working on a project and am in need of a second WiFi booster pack for my MSP430f5529LP.


    I have been using energia code as a base for my project and it has been working great, but I recently decided I need a second MSP + BoosterPack.  Anyways, the TI store doesn't seem to be offering the CC3000 booster pack right now so I am wondering how easy it is to make my cc3000 code compatible with the cc3100 or cc3200 BoosterPack.


    Does anyone have experience with this upgrade?


    Thanks for the information.

  • Create New...