You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • re post #4, bullet point 1 and 3 - as taken from https://stackoverflow.com/questions/3108­3757/esp8266-constantly-restarting

    Get the serial terminal program named "terminal v1.9b by br@y++". While I wrote this answer I was not able to download. When I find the link I'll add in a comment. Run the program and set the baud rate to custom and enter the value 74880 or 74400. With this you'll be able to see the fw messages. In this messages there is the reboot reason code. The codes are :

    0 -> normal startup by power on
    1 -> hardware watch dog reset
    2 -> software watch dog reset (From an exception)
    3 -> software watch dog reset system_restart (Possibly unfed wd got angry)
    4 -> soft restart (Possibly with a restart command)
    5 -> wake up from deep-sleep
    Looking at the provided code you can decide from what reason the chip is restarting.

  • Thanks for your replies. I tried the above but the only readable I got back was something about cal sector 1019 and freq trace enable 0.

    Below code seems to work pretty consistant without resets. Start gets called and I can send additional graphics commands to the screen via the left side of the IDE and they work :

    var exports={};
    var C = {
     OLED_WIDTH                 : 128,
     OLED_CHAR                  : 0x40,
     OLED_CHUNK                 : 128
    };
    // commands sent when initialising the display
    var initCmds = new Uint8Array([
                 0xAE,       // 0 Display off (all pixels off)
                 0xA0, 0x53, // 1 Segment remap (com split, com remap, nibble remap, column remap)
                 0xA1, 0x00, // 3 Display start line
                 0xA2, 0x00, // 5 Display offset
                 0xA4,       // 7 Regular display
                 0xA8, 0x7F, // 8 Set multiplex ratio: 127
                 0xB3, 0x00, // 10 Front clock divider: 0, Fosc: 0
                 0xAB, 0x01, // 12 Enable internal Vdd
                 0xB1, 0xF1, // 14 Set phase periods - 1: 1 clk, 2: 15 clks
                 0xBC, 0x08, // 16 Pre-charge voltage: Vcomh
                 0xBE, 0x07, // 18 COM deselect voltage level: 0.86 x Vcc
                 0xD5, 0x62, // 20 Enable 2nd pre-charge
                 0xB6, 0x0F, // 22 2nd Pre-charge period: 15 clks
                 0xA4, // 24 normal display
                 0xAF, // 25 display on 
                ]);
    
    // commands sent when sending data to the display
    var flipCmds = [
         0x15,// columns
         0, C.OLED_WIDTH - 1,
         0x75, // rows
         0, 127
    ];
    
    function update(options) {
      //TODO
    }
    
    exports.connect = function(i2c, callback, options) {
      update(options);
      var oled = Graphics.createArrayBuffer(C.OLED_WIDTH,­128,4);
    
      var addr = 0x3C;
      if(options) {
        if (options.address) addr = options.address;  
        // reset display if 'rst' is part of options 
        if (options.rst) digitalPulse(options.rst, 0, 10); 
      }
      
      setTimeout(function() {
        // configure the OLED
        initCmds.forEach(function(d) {i2c.writeTo(addr, [0,d]);});
      }, 50);
    
      // write to the screen
      oled.flip = function() { 
        // set how the data is to be sent (whole screen)
        //i2c.writeTo(addr, [0].concat(flipCmds));
        setTimeout(function() {
          flipCmds.forEach(function(d) {i2c.writeTo(addr, [0,d]);});
        }, 50);
        
        setTimeout(function() {
          var chunk = new Uint8Array(C.OLED_CHUNK+1);
          chunk[0] = C.OLED_CHAR;
    
          for (var p=0; p<this.buffer.length; p+=C.OLED_CHUNK) {
            chunk.set(new Uint8Array(this.buffer,p,128), 1);
            i2c.writeTo(addr, chunk);
          } 
          print("flip runs");
        }.bind(this), 100); //wait for flipcmds to run
      };
        
      // set contrast, 0..255
      oled.setContrast = function(c) { i2c.writeTo(addr, 0, 0x81, c); };
    
      // set off
      oled.off = function() { i2c.writeTo(addr, 0, 0xAE); };
    
      // set on
      oled.on = function() { i2c.writeTo(addr, 0, 0xAF); };
    
      // if there is a callback, call it now(ish)
      if (callback !== undefined) setTimeout(callback, 100); //TODO test
      
      // return graphics
      return oled;
    };
    
    
    function start(){
      print("this runs");
      g.clear();
      g.setContrast(128);
      g.setColor(1);
      g.drawString("Hello world 123!",32,32);
      g.drawRect(0,0, 127, 127);
      g.flip(); 
    }
    
    I2C1.setup({scl:D5,sda:D4,bitrate:400000­});
    var g = exports.connect(I2C1, start); 
    

    However if I modify just a bit on this code things get weird. Trying to minify this code gives errors. For example, just commenting the print on line 70 breaks it. When I upload that it returns:

    this runs
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    >F 17
    F 0
    Uncaught SyntaxError: Got '@' expected EOF
     at line 68 col 12
            i2c@(addr, chunk);
               ^
    in function called from system
    

    So, it's really confusing to me what's going on exactly...

About

Avatar for allObjects @allObjects started