7 Replies Latest reply on Nov 19, 2014 1:23 PM by Stan_Gifford

    Arduino sketch using I2c 16x2 lcd causes register dump

    Stan_Gifford

      Firstly - apologies for long post.

       

      The following sketch talks via serial1 to adafruit ultimate GPS at 9600.

       

      A button controls what is sent to a 16x2 i2c LCD - controlled by a LCD library that is untouched between uno and edison.

       

      After downloading sketch I get all sorts of horrible register dumps coming up on the console (I am logged in via the MAC screen command as root) - they seem to be related to I2c - and the display is slightly 'wrong' (Doesn not reflect totally what I sent to it!).

       

      Note - same code with minor mods works fine on uno- note that the rcb_lcd library handles all the i2c comms - but I hope the register dump will point to something without needing to refer to the code.

       

      If there is anything more I can supply, please just ask or PM.

       

      Stan

       

      Actual code library is at: Seeed-Studio/Grove_LCD_RGB_Backlight · GitHub

      Log is below - sketch follows

       

      kernel[192]: [  292.186629] Code: b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 44 c2 8b 15 54 ab b0 c1 89 82 00 b3 ff ff f7 c6 00 02 00 00 74 14 e8 67 f7 0a 00 56 9d <83> c4 04 5b 5e 5f 5d c3 90 8d 74 26 00 56 9d e8 51 f3 0a 00 83

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:22:59 EST):

       

       

       

       

       

       

      kernel[192]: [  292.186655] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G        W  O 3.10.17-poky-edison+ #1

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:22:59 EST):

       

       

       

       

       

       

      kernel[192]: [  292.186660] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:22:59 EST):

       

       

       

       

       

       

      kernel[192]: [  292.186668] task: f6c83d30 ti: f6e1c000 task.ti: f6e1c000

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:22:59 EST):

       

       

       

       

       

       

      kernel[192]: [  292.186729] Stack:

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:22:59 EST):

       

       

       

       

       

       

      kernel[192]: [  292.186796] Call Trace:

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:22:59 EST):

       

       

       

       

       

       

      kernel[192]: [  292.187000] Code: 8b 42 08 a8 08 75 24 31 c9 8d 42 08 89 ca 0f 01 c8 0f ae f0 89 f6 89 e0 25 00 e0 ff ff 8b 40 08 a8 08 75 07 b1 01 89 f0 0f 01 c9 <85> 1d 58 fd b3 c1 75 0d 8d 55 f0 b8 05 00 00 00 e8 8d 34 d9 ff

       

       

       

       

       

       

      [  295.403691] i2c-designware-pci 0000:00:09.1: ===== REGISTER DUMP (i2c) =====

      [  295.403793] i2c-designware-pci 0000:00:09.1: DW_IC_CON:               0x65

      [  295.403877] i2c-designware-pci 0000:00:09.1: DW_IC_TAR:               0x3e

      [  295.403957] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_HCNT:       0x2f8

      [  295.404038] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_LCNT:       0x37b

      [  295.404118] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_HCNT:       0x87

      [  295.404198] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_LCNT:       0x10a

      [  295.404278] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_STAT:         0x0

      [  295.404356] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_MASK:         0x246

      [  295.404437] i2c-designware-pci 0000:00:09.1: DW_IC_RAW_INTR_STAT:     0x10

      [  295.404516] i2c-designware-pci 0000:00:09.1: DW_IC_RX_TL:             0x20

      [  295.404595] i2c-designware-pci 0000:00:09.1: DW_IC_TX_TL:             0x20

      [  295.404674] i2c-designware-pci 0000:00:09.1: DW_IC_ENABLE:            0x1

      [  295.404753] i2c-designware-pci 0000:00:09.1: DW_IC_STATUS:            0x2

      [  295.404831] i2c-designware-pci 0000:00:09.1: DW_IC_TXFLR:             0x2

      [  295.404910] i2c-designware-pci 0000:00:09.1: DW_IC_RXFLR:             0x0

      [  295.404988] i2c-designware-pci 0000:00:09.1: DW_IC_TX_ABRT_SOURCE:    0x0

      [  295.405067] i2c-designware-pci 0000:00:09.1: DW_IC_DATA_CMD:          0x0

      [  295.405145] i2c-designware-pci 0000:00:09.1: ===============================

      [  295.405257] CPU: 1 PID: 290 Comm: sketch.elf Tainted: G        W  O 3.10.17-poky-edison+ #1

      [  295.405262] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [  295.405269] task: f5f11bd0 ti: f53c8000 task.ti: f53c8000

      [  295.405331] Stack:

      [  295.405400] Call Trace:

      [  295.405835] Code: b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 44 c2 8b 15 54 ab b0 c1 89 82 00 b3 ff ff f7 c6 00 02 00 00 74 14 e8 67 f7 0a 00 56 9d <83> c4 04 5b 5e 5f 5d c3 90 8d 74 26 00 56 9d e8 51 f3 0a 00 83

      [  295.405861] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W  O 3.10.17-poky-edison+ #1

      [  295.405866] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [  295.405874] task: c1b02120 ti: c1afc000 task.ti: c1afc000

      [  295.405935] Stack:

      [  295.406003] Call Trace:

      [  295.406244] Code: 8b 42 08 a8 08 75 24 31 c9 8d 42 08 89 ca 0f 01 c8 0f ae f0 89 f6 89 e0 25 00 e0 ff ff 8b 40 08 a8 08 75 07 b1 01 89 f0 0f 01 c9 <85> 1d 58 fd b3 c1 75 0d 8d 55 f0 b8 05 00 00 00 e8 8d 34 d9 ff

      [  295.536093] i2c-6: recovery ignore

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:02 EST):

       

       

       

       

       

       

      kernel[192]: [  295.405257] CPU: 1 PID: 290 Comm: sketch.elf Tainted: G        W  O 3.10.17-poky-edison+ #1

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:02 EST):

       

       

       

       

       

       

      kernel[192]: [  295.405262] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:02 EST):

       

       

       

       

       

       

      kernel[192]: [  295.405331] Stack:

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:02 EST):

       

       

       

       

       

       

      kernel[192]: [  295.405400] Call Trace:

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:02 EST):

       

       

       

       

       

       

      kernel[192]: [  295.405835] Code: b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 44 c2 8b 15 54 ab b0 c1 89 82 00 b3 ff ff f7 c6 00 02 00 00 74 14 e8 67 f7 0a 00 56 9d <83> c4 04 5b 5e 5f 5d c3 90 8d 74 26 00 56 9d e8 51 f3 0a 00 83

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:02 EST):

       

       

       

       

       

       

      kernel[192]: [  295.405861] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W  O 3.10.17-poky-edison+ #1

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:02 EST):

       

       

       

       

       

       

      kernel[192]: [  295.405866] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:03 EST):

       

       

       

       

       

       

      kernel[192]: [  295.405874] task: c1b02120 ti: c1afc000 task.ti: c1afc000

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:03 EST):

       

       

       

       

       

       

      kernel[192]: [  295.405935] Stack:

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:03 EST):

       

       

       

       

       

       

      kernel[192]: [  295.406003] Call Trace:

       

       

       

       

       

       

       

       

       

      Broadcast message from systemd-journald@Edison_1 (Wed 2014-11-12 20:23:03 EST):

       

       

       

       

       

       

      kernel[192]: [  295.406244] Code: 8b 42 08 a8 08 75 24 31 c9 8d 42 08 89 ca 0f 01 c8 0f ae f0 89 f6 89 e0 25 00 e0 ff ff 8b 40 08 a8 08 75 07 b1 01 89 f0 0f 01 c9 <85> 1d 58 fd b3 c1 75 0d 8d 55 f0 b8 05 00 00 00 e8 8d 34 d9 ff

       

       

       

       

       

       

      [  298.623119] i2c-designware-pci 0000:00:09.1: ===== REGISTER DUMP (i2c) =====

      [  298.623219] i2c-designware-pci 0000:00:09.1: DW_IC_CON:               0x65

      [  298.623294] i2c-designware-pci 0000:00:09.1: DW_IC_TAR:               0x3e

      [  298.623366] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_HCNT:       0x2f8

      [  298.623439] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_LCNT:       0x37b

      [  298.623511] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_HCNT:       0x87

      [  298.623583] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_LCNT:       0x10a

      [  298.623656] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_STAT:         0x0

      [  298.623727] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_MASK:         0x246

      [  298.623799] i2c-designware-pci 0000:00:09.1: DW_IC_RAW_INTR_STAT:     0x10

      [  298.623871] i2c-designware-pci 0000:00:09.1: DW_IC_RX_TL:             0x20

      [  298.623942] i2c-designware-pci 0000:00:09.1: DW_IC_TX_TL:             0x20

      [  298.624014] i2c-designware-pci 0000:00:09.1: DW_IC_ENABLE:            0x1

      [  298.624085] i2c-designware-pci 0000:00:09.1: DW_IC_STATUS:            0x2

      [  298.624156] i2c-designware-pci 0000:00:09.1: DW_IC_TXFLR:             0x2

      [  298.624227] i2c-designware-pci 0000:00:09.1: DW_IC_RXFLR:             0x0

      [  298.624298] i2c-designware-pci 0000:00:09.1: DW_IC_TX_ABRT_SOURCE:    0x0

      [  298.624369] i2c-designware-pci 0000:00:09.1: DW_IC_DATA_CMD:          0x0

      [  298.624439] i2c-designware-pci 0000:00:09.1: ===============================

      [  298.624542] CPU: 0 PID: 290 Comm: sketch.elf Tainted: G        W  O 3.10.17-poky-edison+ #1

      [  298.624547] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [  298.624554] task: f5f11bd0 ti: f53c8000 task.ti: f53c8000

      [  298.624616] Stack:

      [  298.624683] Call Trace:

      [  298.625125] Code: b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 44 c2 8b 15 54 ab b0 c1 89 82 00 b3 ff ff f7 c6 00 02 00 00 74 14 e8 67 f7 0a 00 56 9d <83> c4 04 5b 5e 5f 5d c3 90 8d 74 26 00 56 9d e8 51 f3 0a 00 83

      [  298.625149] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G        W  O 3.10.17-poky-edison+ #1

      [  298.625154] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [  298.625163] task: f6c83d30 ti: f6e1c000 task.ti: f6e1c000

      [  298.625223] Stack:

      [  298.625291] Call Trace:

      [  298.625496] Code: 8b 42 08 a8 08 75 24 31 c9 8d 42 08 89 ca 0f 01 c8 0f ae f0 89 f6 89 e0 25 00 e0 ff ff 8b 40 08 a8 08 75 07 b1 01 89 f0 0f 01 c9 <85> 1d 58 fd b3 c1 75 0d 8d 55 f0 b8 05 00 00 00 e8 8d 34 d9 ff

      [  298.626134] i2c-6: recovery ignore

       

       

       

       

       

       

       

       

       

      /*

        UHURU module

      GPS Navigation

      Accelerometer

      Output to LCD

      */

      #include <Wire.h>

      #include "rgb_lcd.h"

      #include <TinyGPS++.h>

       

       

      rgb_lcd lcd;

      // The TinyGPS++ object

      TinyGPSPlus gps;

      const int colorR = 255;

      const int colorG = 0;

      const int colorB = 0;

      static const uint32_t GPSBaud = 9600;

       

       

       

       

      static const int RXPin = 4, TXPin = 3;

      // ABove just for reference - on Edison we will be using serial 1 which maps to those ports

      //

       

       

      int Button=6;

      int lastButton=0;

      int buttoncmd= 0;

      int lastcmd =-1;

       

       

      #define maxbut 3

       

       

      #define DisplayLocation 0

      #define DisplayTime 1

      #define DisplaySpeed 2

      #define DisplaySatellites 3

      uint32_t timer;

       

       

       

       

       

       

       

       

       

       

       

       

      #define GPSECHO  false

       

       

      void setup() {

        pinMode(Button,INPUT);

        Serial.begin(115200);

        Serial1.begin(GPSBaud);   // -> to talk to GPS

       

         Serial.println("FullExample.ino");

        Serial.println("An extensive example of many interesting TinyGPS++ features");

        Serial.print("Testing TinyGPS++ library v. "); Serial.println(TinyGPSPlus::libraryVersion());

        Serial.println("by Mikal Hart");

        Serial.println();

        Serial.println("Sats HDOP Latitude   Longitude   Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum");

        Serial.println("          (deg)      (deg)       Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail");

        Serial.println("---------------------------------------------------------------------------------------------------------------------------------------");

       

        // initialize the library with the numbers of the interface pins

        lcd.begin(16, 2);

       

       

        lcd.setRGB(colorR, colorG, colorB);

       

      // GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);

        // uncomment this line to turn on only the "minimum recommended" data

        //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);

        // For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since

        // the parser doesn't care about other sentences at this time

       

       

        // Set the update rate

      // GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate

        // For the parsing code to work nicely and have time to sort thru the data, and

        // print it out we don't suggest using anything higher than 1 Hz

       

       

        // Request updates on antenna status, comment out to keep quiet

        //  GPS.sendCommand(PGCMD_ANTENNA);

       

       

        // the nice thing about this code is you can have a timer0 interrupt go off

        // every 1 millisecond, and read data from the GPS for you. that makes the

        // loop code a heck of a lot easier!

       

        // Ask for firmware version

      //  Serial1.println(PMTK_Q_RELEASE);

        // set up the LCD's number of columns and rows:

        lcd.begin(16, 2);

        // Print a message to the LCD.

        lcd.print("Uhuru:Starting");

        lcd.setCursor(0, 1);

        lcd.print("GPS: No Fix");

       

       

      }

       

       

       

       

      void loop() {

        float lat;

        float lon;

        float w1;

        int w1int;

        if (digitalRead(Button) == 0)

          lastButton=0;

        if (digitalRead(Button) == 1 && lastButton==0 && gps.location.isValid())

        {

          buttoncmd++;

          if (buttoncmd > maxbut)

            buttoncmd=0;

          lastButton=1;

        }

        lcd.setCursor(0, 1);

        // print the number of seconds since reset:

       

       

       

       

       

        // approximately every 2 seconds or so, print out the current stats

        if (millis() - timer > 500)

        {

          timer = millis();

          if (!gps.location.isValid())

          {

            lcd.setCursor(0, 1);

            lcd.print("GPS: No Fix ");

            lcd.print(millis() / 1000);

          }

          else

          {

            if (lastcmd != buttoncmd)

            {

              lcd.clear();

              lastcmd=buttoncmd;

            }

            switch (buttoncmd)

            {

            case DisplayLocation:

              lcd.setCursor(0,0);

              lat=gps.location.lat();

              lon=gps.location.lng();

      //       if (GPS.lat=='S')

      //         lat=lat * -1;

      //        if (GPS.lon=='W')

      //         lon=lon * -1;         

              lat=lat/100;

              w1int=lat;

              w1=lat-w1int;

              w1=(w1*100)/60;

              lat=w1int+w1;     

              lon=lon/100;

              w1int=lon;

              w1=lon-w1int;

              w1=(w1*100)/60;

              lon=w1int+w1;

              lcd.print("Lat: ");

              lcd.print(lat, 6);

              lcd.setCursor(0,1);

              lcd.print("Lon: ");

              lcd.print(lon,6);

              break;

            case DisplayTime:

              lcd.setCursor(0,0);

              lcd.print("UTC Date/Time");

              break;

            case DisplaySpeed:

              lcd.setCursor(0,0);

              lcd.print("Speed");

              break;

            case DisplaySatellites:    

              lcd.setCursor(0,0);

              lcd.print("Satellites");

              break;

            default:

              break;

            }

          }

          /*

             Serial.print("\nTime: ");

           Serial.print(GPS.hour, DEC); Serial.print(':');

           Serial.print(GPS.minute, DEC); Serial.print(':');

           Serial.print(GPS.seconds, DEC); Serial.print('.');

           Serial.println(GPS.milliseconds);

           Serial.print("Date: ");

           Serial.print(GPS.day, DEC); Serial.print('/');

           Serial.print(GPS.month, DEC); Serial.print("/20");

           Serial.println(GPS.year, DEC);

           Serial.print("Fix: "); Serial.print((int)GPS.fix);

           Serial.print(" quality: "); Serial.println((int)GPS.fixquality);

           if (GPS.fix) {

           Serial.print("Location: ");

           Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);

           Serial.print(", ");

           Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);

           Serial.print("Fixed Lat: ");

           Serial.println(GPS.latitude_fixed);

           Serial.print("Fixed Lon: ");

           Serial.println(GPS.longitude_fixed);

          

           Serial.print("Speed (knots): "); Serial.println(GPS.speed);

           Serial.print("Angle: "); Serial.println(GPS.angle);

           Serial.print("Altitude: "); Serial.println(GPS.altitude);

           Serial.print("Satellites: "); Serial.println((int)GPS.satellites);

           }

           */

        }

        smartDelay(0);

         printInt(gps.satellites.value(), gps.satellites.isValid(), 5);

        printInt(gps.hdop.value(), gps.hdop.isValid(), 5);

        printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);

        printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);

        printInt(gps.location.age(), gps.location.isValid(), 5);

        printDateTime(gps.date, gps.time);

        printFloat(gps.altitude.meters(), gps.altitude.isValid(), 7, 2);

        printFloat(gps.course.deg(), gps.course.isValid(), 7, 2);

        printFloat(gps.speed.kmph(), gps.speed.isValid(), 6, 2);

        printStr(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.value()) : "*** ", 6);

        Serial1.println("");

      }

       

       

       

       

       

       

      // This custom version of delay() ensures that the gps object

      // is being "fed".

      static void smartDelay(unsigned long ms)

      {

        unsigned long start = millis();

        do

        {

          while (Serial1.available())

            gps.encode(Serial1.read());

        } while (millis() - start < ms);

      }

       

       

       

       

      static void printInt(unsigned long val, bool valid, int len)

      {

        char sz[32] = "*****************";

        if (valid)

          sprintf(sz, "%ld", val);

        sz[len] = 0;

        for (int i=strlen(sz); i<len; ++i)

          sz[i] = ' ';

        if (len > 0)

          sz[len-1] = ' ';

        Serial.print(sz);

        smartDelay(0);

      }

       

       

      static void printDateTime(TinyGPSDate &d, TinyGPSTime &t)

      {

        if (!d.isValid())

        {

          Serial.print("********** ");

        }

        else

        {

          char sz[32];

          sprintf(sz, "%02d/%02d/%02d ", d.month(), d.day(), d.year());

          Serial.print(sz);

        }

       

        if (!t.isValid())

        {

          Serial.print("******** ");

        }

        else

        {

          char sz[32];

          sprintf(sz, "%02d:%02d:%02d ", t.hour(), t.minute(), t.second());

          Serial.print(sz);

        }

       

       

        printInt(d.age(), d.isValid(), 5);

        smartDelay(0);

      }

       

       

      static void printStr(const char *str, int len)

      {

        int slen = strlen(str);

        for (int i=0; i<len; ++i)

          Serial.print(i<slen ? str[i] : ' ');

        smartDelay(0);

      }

      static void printFloat(float val, bool valid, int len, int prec)

      {

        if (!valid)

        {

          while (len-- > 1)

            Serial.print('*');

          Serial.print(' ');

        }

        else

        {

          Serial.print(val, prec);

          int vi = abs((int)val);

          int flen = prec + (val < 0.0 ? 2 : 1); // . and -

          flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;

          for (int i=flen; i<len; ++i)

            Serial.print(' ');

        }

        smartDelay(0);

      }

        • 1. Re: Arduino sketch using I2c 16x2 lcd causes register dump
          Intel_Peter

          Hello Stan_Gifford,

           

          I have an 16x2 LCD from adafruit, I will try to replicate your case and will reply as soon as I have a suggestion for you.

           

          Regards,

                      Peter

          • 2. Re: Arduino sketch using I2c 16x2 lcd causes register dump
            Stan_Gifford

            Well I was about to just post that I had tested all the other I2c LCD examples from the library with no issues however............

             

            I opened the web window on my mac to start this post then the edison console started freaking out with the register dumps - this was a couple of minutes after the last example program (Custom Character) - I had ran it and just left it

             

            - So I removed the sketch and rebooted

            - Now if I download a new sketch, the display does not change - but I get register dumps

             

            So my theory is that the i2c bus needs to reset/transition when a new i2c sketch runs - I will do some experimentation with the good and trusty logic analyser

             

            Stan

            • 3. Re: Arduino sketch using I2c 16x2 lcd causes register dump
              Intel_Peter

              Hello Stan_Gifford,

               

              What's happening to you is really a strange issue, I ran some tests with my LCD and it worked fine, you said the library you're using is untouched between the Uno and the Edison, so maybe that's the where the issue is generated, check this post where they talk about a very similar subject, also in that post there is this link to a post Mikal.Hart did with some LCD library fixes.

               

              If you have any more doubts, don't hesitate to ask.

               

              Regards,

                          Peter

              • 4. Re: Arduino sketch using I2c 16x2 lcd causes register dump
                mcabral

                I also had problems using an I2C LCD - please take a look at this post to see if it helps.

                 

                https://communities.intel.com/message/258013#258013

                • 5. Re: Arduino sketch using I2c 16x2 lcd causes register dump
                  Stan_Gifford

                  Thanks Peter - tis a mystery.

                   

                  Anyway, the way I am proceeding is by porting the code to the Eclipse IDE.

                   

                  I have a simple part of the code running using the lcd library built into the ide and it works (mostly).

                   

                  The good news is that I have not had any register dumps come up - however a couple of times the display did not reflect reality - I had send the command to display some stuff on line2 (basicicly I stole the code from the helloworld example) but on a couple of occasions the reposition cusrsor did not work and the next line of text I sent came out on line 1.

                   

                  Have not yet had time to diagnose - been busy porting TinyGPSplus - but I do have a theory (which I am happy for you to shoot down in flames) (it also may have bearing on Mikal's solution below)

                   

                  The theory is that on the arduino, the I2c bus comes up at 100 hz however I believe on the edison it is by default 400 hz. - Could it be that the bus is just too fast for the I2c LCD?

                   

                  I believe I did see something about setting the bus to run slower and (in my copious free time) I will look at the original sketch and see if I can apply the change.

                   

                  As I said however, after spending the weekend getting the IDE working (new to eclipse) I am now doing my stuff for the edison using that.

                   

                  Does present some challenges - a lot of the code uses the arduino millis function which I had to write....................

                   

                  Stan

                  • 6. Re: Arduino sketch using I2c 16x2 lcd causes register dump
                    Intel_Peter

                    Hello Stan_Gifford,

                     

                    If you check the Edison Module Hardware Guide, in page 15, in the I2C features, it says that the I2C in the Edison has two modes, Standard mode (with data rates up to 100 kbps) and Fast mode (with data rates up to 400 kbps). You may be able to change the speed of the I2C through some method of your library or maybe create it if there isn't one.

                    However if get it working I invite you to share your results in the communities.If you have any more doubts don't hesitate to ask.

                     

                    Regards,

                                Peter

                    • 7. Re: Arduino sketch using I2c 16x2 lcd causes register dump
                      Stan_Gifford


                      Hi Peter,

                      WIll defintly post once I have finished.

                       

                      Progress is good - the TinyGPS library appears to work. I am reading data from Serial1 (/dev/ttyMFD2 - from memory) and passing it to the TinyGPSplus for decode and it tells me I have valid GPS data.

                       

                      As mentioned previously now I have the edison IDE up and am rapidly getting expertise in it, progress is excellent - A suggestion would be a 'How do I get to the point of creating and deploying a helloworld to the edison via SSH in Eclipse' document would be good (for new players who have never used eclipse before).

                       

                      Looking at my original Arduino code I can see some improvements which will be incorporated in the edison code. This leads me to yet another theory which I will outline below;

                       

                      Currently on the arduino, each pass thru loop writes GPS Data to the LCD depending on what has been selected via the button. On a non-preemptive operating system (if you can call the arduino environment an operating system), this is fine - you know that nothing will disturb what you are doing.

                       

                      When I ported the code to the edison arduino environment however I believe that one needs to be aware that you are on a pre-emptive OS (you are just another process running). I am wondering if my i2c calls were interupted and because I was chucking huge amounts of data at the LCD this is quite probable. This may explain why occasionaly when I ran the i2c LCD helloworld example which was built using eclipse, a couple of times the display got corrupted (in one instance I lost the 'Cursor position' call).

                       

                      If ths is the case perhaps what either I need or the I2c library needs is a non-preempt barrier while i2c operations are executing.

                       

                      Note - this is a theory only but it does seem to explain the behaviour of what I am seeing.

                       

                      FWIW this is what I am writing;

                       

                      A push button is connected to GPIO 6 - this pin has a rising edge interupt configured which sets the current LCD display mode (volatile). Debouncing is performed by disregarding the button push if 500 milliseconds have not passed. (**WORKING**)

                       

                      An Adafruit Ultimate GPS module is connected to Serial1.

                       

                      The data from Serial1 is passed to a ported TinyGPSplus library which handles GPS data decode - the library has a method to determine if the data held in the GPS library is valid GPS data. (**WORKING**)

                       

                      An I2c LCD is connected to SDA/SCL (a4, a5) (**WORKING**)

                       

                      The general loop uses the current display mode (set by button interupt) and displays the appropriate data to the LCD. (Note in the arduino sketch it displayed the data each pass thru the loop - on the edison I will change this to only display the data if it has changed (or the display mode has changed).

                       

                      I call this code Uhuru (Star Trek) however she was the communications officer - must look up the navigation officer and perform a rename :-) because.....

                       

                      Once all this is working, I want to integrate a compass/mag module (Overview | Adafruit HMC5883L Breakout - Triple-Axis Magnetometer/Compass Sensor | Adafruit Learning System) into the system.

                       

                      Then I end up with a GP module that knows where it is, what direction it is pointing, the speed and orrientation. This whole module will then pass its data to other boards which can operate on the data. To be honest, using the edison is overkill for just this single piece of code but it is a great learning exercise. Also this is but one program executing on the edison - as I design more bits, there is possibly no reason why more 'programs' that provide more functionality cannot run as well on the edison.

                       

                      FInally once it is all working, I will probably remove the LCD - which in some respects is used for 'debug' purposes.

                       

                      Stan