• After more than 10 days; I have solved the crash problem. It was in jshardware.h.
    When the program was to store the bitrate in the address, the address was not divisible by 4.

    I hope it will run on a normal Espruino too. I haven't tested it yet.

    I have also chaged a lot in i2c_master.c

    //#define i2c_master_wait(x)    os_delay_us(x/4) // do{}while(0)
    

    When x is under 4 then the result was 0. So the waiting in the program was not good.

    Now I use this

    [#define](https://forum.espruino.com/search/?q=%23define) i2c_master_wait(x)    os_delay_us(x*y)
    

    and sat it up so it could wait between 1 and 4 us.

    if(bitrate > 400000) {bitrate=400000;}
    if(bitrate < 100000) {bitrate=100000;}
    y = 400000/bitrate;
    

    I don't know the bitrate, but I have it running with wii nunchuck and htu21d at the same time.

    Se the attachment files.

    Are there sombody, that have some equepment to test the bitrate, and to try it out?

    And clockstreching on all places where the clocksignal goes from 0 to 1.

    before any change:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v85.134 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 512KB:256/256, manuf 0xc8 chip 0x4013
    >  I2C1.setup({scl:D0, sda:D2, bitrate:400000});
     ets Jan  8 2013,rst cause:1, boot mode:(3,7)
    load 0x40100000, len 1396, room 16
    tail 4
    chksum 0x89
    load 0x3ffe8000, len 776, room 4
    tail 4
    chksum 0xe8
    load 0x3ffe8308, len 540, room 4
    tail 8
    chksum 0xc0
    csum 0xc0
    2nd boot version : 1.4(b1)
      SPI Speed      : 40MHz
      SPI Mode       : QIO
      SPI Flash Size & Map: 4Mbit(256KB+256KB)
    jump to run user1 @ 1000
    

    after change in:

    Espruino/Espruino/src/jshardware.h

    /// Settings passed to jshI2CSetup to set I2C up
    typedef struct {
      int bitrate;
      Pin pinSCL;
      Pin pinSDA;
    //  int bitrate;
      // timeout?
    } PACKED_FLAGS JshI2CInfo;
    
    
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v85.134 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 512KB:256/256, manuf 0xc8 chip 0x4013
    >  I2C1.setup({scl:D0, sda:D2, bitrate:400000});
    =undefined
    >
    

    after change in:

    Espruino/Espruino/targets/esp8266/i2c_master.c

    _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v85.134 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 512KB:256/256, manuf 0xc8 chip 0x4013
    >echo(0);
    {
      "sdkVersion": "1.5.3(aec24ac9)",
      "cpuFrequency": 160, "freeHeap": 9528, "maxCon": 10,
      "flashMap": "512KB:256/256",
      "flashKB": 512,
      "flashChip": "0xc8 0x4013"
     }
    23.66751708984
    44.48982482910
    10.90604566494
    /
    T   = 23.667 °C
    RH  = 44.489  %
    DEW = 10.906 °C
     
    new Uint8Array([127, 127, 81, 130, 144, 167])   \
    {
      "joy": { "x": 127, "y": 127 },
      "acc": { "x": 325, "y": 522, "z": 578 },
      "btn": { "z": false, "c": false }
     }
    =undefined
    23.66751708984
    44.48982482910
    10.90604566494
    \
    T   = 23.667 °C
    RH  = 44.489  %
    DEW = 10.906 °C
     
    new Uint8Array([127, 127, 81, 130, 144, 167])   /
    {
      "joy": { "x": 127, "y": 127 },
      "acc": { "x": 325, "y": 522, "z": 578 },
      "btn": { "z": false, "c": false }
     }
    

    2 Attachments

About

Avatar for Frida @Frida started