TheArduinoGuy

Members
  • Content count

    13
  • Joined

  • Last visited

About TheArduinoGuy

  • Rank
    Member

Contact Methods

  • Website URL
    http://thearduinoguy.org/

Profile Information

  • Location
    London, England
  • Interests
    Arduino, ArduBoy, ESP8266, Raspberry Pi.
  • Github
    https://github.com/thearduinoguy

Recent Profile Visitors

139 profile views
  1. I am trying to receive I2C data from a temperature sensor and print it to the Serial Monitor. The code works up to a point and then the device resets. I think it may be something to do with the Watchdog but not sure how to rectify it. Please help. My code is... #include <Wire.h> #include <Si7006.h> Si7006 tempNHum; void setup() { // Initialize the Serial1 port: Serial1.begin(9600); Serial1.flush(); delay(20); Serial1.println("Si7006-A20 example sketch"); // Initialize the Si7006 library // You can pass nothing to light.begin() for the default I2C address (0x40) tempNHum.begin(); if (!tempNHum.begin()) { Serial1.println("Couldn't find Si7006"); while (1) delay(1); // Do Nothing } // Get factory ID from sensor: // (Just for fun, you don't need to do this to operate the sensor) char ID[8]; if (tempNHum.getDeviceID(ID)) { Serial1.print("Got Sensor Part ID: 0X"); // Default value of MSB 0x06 for(int i = 0; i < sizeof(ID); i++) { Serial1.print(ID[i],HEX); } Serial1.println(); } // Most library commands will return true if communications was successful, // and false if there was a problem. You can ignore this returned value, // or check whether a command worked correctly and retrieve an error code: else { byte error = tempNHum.getError(); printError(error); } // Gets the Firmware Version of the chip // Default value is 0xFF for version 1.0 or 0x20 for version 2.0 byte firmwareVer; if(tempNHum.getFirmwareVer(firmwareVer)) { Serial1.print("Got Sensor Firmware Version: 0X"); Serial1.println(firmwareVer,HEX); } else { byte error = tempNHum.getError(); printError(error); } // Gets the contents RH/Temp User Register of the sensor byte resolution; boolean voltage, heaterStatus; tempNHum.getTempControl(resolution, voltage, heaterStatus); Serial1.print("Resolution is: "); Serial1.println(resolution); // Setting the resolution and heater disable resolution = 0x00; heaterStatus = false; tempNHum.setTempControl(resolution, heaterStatus); // Getting heater current byte heaterCurrent; tempNHum.getHeaterControl(heaterCurrent); Serial1.print("Heater Current is "); Serial1.println(heaterCurrent); // Setting heater current tempNHum.setHeaterControl(heaterCurrent); } void loop() { float temp; float humidity; boolean mode = false; // Read temperature if(tempNHum.getTemperature(temp, mode)) { Serial1.print("Temp *C = "); Serial1.println(temp); } else{ Serial1.println("Failed to read temperature"); byte error = tempNHum.getError(); printError(error); } // Read humidity if(tempNHum.getHumidity(humidity, mode)) { Serial1.print("Humidity = "); Serial1.print(humidity); Serial1.println("%"); } else { Serial1.println("Failed to read humidity"); byte error = tempNHum.getError(); printError(error); } delay(1000); } void printError(byte error) { // If there's an I2C error, this function will // print out an explanation. Serial1.print("I2C error: "); Serial1.print(error,DEC); Serial1.print(", "); switch(error) { case 0: Serial1.println("success"); break; case 1: Serial1.println("data too long for transmit buffer"); break; case 2: Serial1.println("received NACK on address (disconnected?)"); break; case 3: Serial1.println("received NACK on data"); break; case 4: Serial1.println("other error"); break; default: Serial1.println("unknown error"); } } The output is... Got Sensor Part ID: 0X2653FFFFFFB853FFFFFF8244FFFFFF8244 Got Sensor Firmware Version: 0X0 Resolution is: 0 HeaterSi7006-A20 example sketch Got Sensor Part ID: 0X2653FFFFFFB853FFFFFF8244FFFFFF8244 Got Sensor Firmware Version: 0X0 Resolution is: 0 HeaterSi7006-A20 example sketch Got Sensor Part ID: 0X2653FFFFFFB853FFFFFF8244FFFFFF8244 Got Sensor Firmware Version: 0X0 Resolution is: 0 HeaterSi7006-A20 example sketch Got Sensor Part ID: 0X2653FFFFFFB853FFFFFF8244FFFFFF8244 As you can see, it gets as far as printing the word 'Heater' and then resets. Any ideas please? Thanks in advance. Mike.
  2. The board i'm using has the appropriate resistors to deal with that so that is not an issue.
  3. No that didn't work either. The received values differ from what I get when using an Arduino Nano. It's very frustrating.
  4. Thanks for those suggestions. I have already done something similar but I will try again. I don't have another MSP430 board so will send the serial via an Arduino Nano. I will let you know how I get on. Cheers, Mike
  5. No, idea. It wasn't my code originally. I'm sure there was a reason for it. I'll try them as a char and see if it still works. Thanks.
  6. Has anybody else with an MSP430 (even better still the FR5969 variant) managed to get serial at 9600 baud to be read successfully by the device?
  7. Wow, thanks Fred. Real friendly and helpful of you.
  8. OK that was something at the terminal side rather the MSP430 side. However, I have discovered something weird going on... I have a Nextion display that communicates over serial at 9600 baud. When you press a button it sends a text string with codes to show which button on which page has been pressed etc. When the screen is connected to an Arduino Nano I get valid strings back which look like: "65 0 4 0 ffff ffff ffff" But when connected to the MSP430 the message back from the display is just garbled. I can send data FROM the MSP430 to the display perfectly fine and control it no problem. But data received back from the display is garbled. The display is fine (as shown when connecting it to a Nano) so what is going on here?
  9. I don't really want to be porting over to a new IDE. I'm used to the Arduino IDE and therefore Energia. I've had a look at CCS at it is way too complicated for me. I have 2 serial ports showing up. One is /dev/ttyACM0 which I use to upload the sketch on. The other is /dev/ttyACM1 which I use for with Serial1 to send debug info. I would have thought there would be a way of sending data over the ttyACM0 port (Serial2 or just Serial ?) via the JTAG programmer?
  10. I have the following simple code set up to echo whatever I type into the Serial Monitor, but as HEX with a comma separating each byte (So I can also see control codes) : int inByte = 0; // incoming serial byte byte buffer[30]; // buffer for bytes coming from HMI. void setup() { // Enable USCI_A1 RX interrupt // start serial port at 9600 bps: Serial1.begin(9600); Serial1.print("READY"); } void loop() { int bytesread = 0; // if we get a valid byte, read analog ins: if (Serial1.available()>0) { // there are bytes in the serial buffer to read while(Serial1.available()>0) { // every time a byte is read it is expunged // from the serial buffer so keep reading the buffer until all the bytes // have been read. byte inbyte = Serial1.read(); buffer[bytesread] = inbyte; bytesread++; } } for (int x = 0; x < bytesread; x++) { Serial1.print(buffer[x], HEX); Serial1.print(","); } } However, it is behaving a bit weird and unexplained. If I enter ABCDE and press ENTER I would expect the output to be: 41,42,43,44,45,D,A But instead it just prints 41, When I enter ABCDE and ENTER a second time I then get: 42,43,44,45,D,A,41 Which is the missing characters from the first entry pluis the first character only from the second. This is not what I expected. Device is an MSP430-5969 Any ideas please? Thanks, Mike
  11. I have a PCB made by a third party that has an MSP430-5969 on it. My task is to program new firmware to the device. The board has 4 pins for a JTAG connector which I have connected to the TI MSP-FET Flash Emulation Tool. I am able to successfully upload code to the device. However, pins 2.5 and 2.6 go to an external display with a serial interface (Nextion display). There are also 2 I2C pins broken out If I connect the TX/RX pins of the MSP-FET to those pins I am able to send data from the board using Serial1 to the Serial Monitor window in Energia. Now, this means that whenever the display is plugged in I have no way of getting debug information from the board. Is there any other way I could do this, perhaps over the JTAG connections? Please help. Thanks, Mike
  12. I am trying to port some code over that was originally written in Code Composer Studio to Energia and I have this function: void Send_Command_Screen(unsigned char UARTA1_TX_ARRAY[]) { unsigned int i; unsigned int len; len = strlen (UARTA1_TX_ARRAY); //Send command for(i=0 ; i<len ; i++) { while(!(UCA1IFG & UCTXIFG)); //Loop until the uart is ready UCA1TXBUF = UARTA1_TX_ARRAY[i]; } //Send three times 0xff to end the command for(i=0 ; i<3 ; i++) { while(!(UCA1IFG & UCTXIFG)); //Loop until the uart is ready UCA1TXBUF = 0xff; } } and it is throwing up this error: sketch/Screen_Nextion.h: In function 'void Send_Command_Screen(const unsigned char*)': Screen_Nextion.h:87: error: invalid conversion from 'const unsigned char*' to 'const char*' [-fpermissive] Line 87 is right after the len = strlen (UARTA1_TX_ARRAY); line Can anyone please assist with why I am getting this error please? Thanks.
  13. Can some explain what the following error messages are all about and why I am getting them when trying to compile the standard Blink example please? Plus, how to fix this. Thanks. C:\Users\Mike\Downloads\energia-1.6.10E18-windows\energia-1.6.10E18\hardware\energia\msp430\cores\msp430\atof.c: In function 'atof': C:\Users\Mike\Downloads\energia-1.6.10E18-windows\energia-1.6.10E18\hardware\energia\msp430\cores\msp430\atof.c:71:9: warning: floating constant exceeds range of 'double' [-Woverflow] C:\Users\Mike\Downloads\energia-1.6.10E18-windows\energia-1.6.10E18\hardware\energia\msp430\cores\msp430\wiring_analog.c:65:0: warning: "DEFAULT_READ_RESOLUTION" redefined [enabled by default] C:\Users\Mike\Downloads\energia-1.6.10E18-windows\energia-1.6.10E18\hardware\energia\msp430\cores\msp430\wiring_analog.c:35:0: note: this is the location of the previous definition C:\Users\Mike\Downloads\energia-1.6.10E18-windows\energia-1.6.10E18\hardware\energia\msp430\cores\msp430\avr\dtostrf.c: In function 'dtostrf': C:\Users\Mike\Downloads\energia-1.6.10E18-windows\energia-1.6.10E18\hardware\energia\msp430\cores\msp430\avr\dtostrf.c:36:3: warning: incompatible implicit declaration of built-in function 'sprintf' [enabled by default] C:\Users\Mike\Downloads\energia-1.6.10E18-windows\energia-1.6.10E18\hardware\energia\msp430\cores\msp430\Stream.cpp: In member function 'bool Stream::find(char*)': C:\Users\Mike\Downloads\energia-1.6.10E18-windows\energia-1.6.10E18\hardware\energia\msp430\cores\msp430\Stream.cpp:78:30: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]