• So, here's the problems I am having with interfacing by SPI to BM019.
    Before I show the code and output here are some points of note;

    1. The code is just for test to see if I can get consistent communications going.
    2. I'm sending 0x55 (85) because the BM019 documentation says this should just echo back 0x55.
    3. I have tried just about every permutation and combination I can think of in terms of pins high/low, implementing in different ways to make it faster etc. I've spend quite some hours on this so this is my last shot before I switch to Arduino.
    4. I've checked my wiring loads of times and haven't spotted anything wrong there.
    5. It seems odd that I sometimes get a 0x55 response, which is why I suspected a timing issue.
    6. The BM019 documentation says I have to do a wake-up pulse so that' what I do first.
    7. I am using software SPI here, but I find the same result on hardware SPI.
    8. The output follows the code below. Note, inconsistency of output.

    If anyone has any suggestions they will be most grateful received :-)

    Here's the code...

    print("Setting up SPI");
    var spi=new SPI();
    
    spi.setup(
      {
    	sck:D19,
    	miso:D22,
    	mosi:D20,
    	mode:0,
    	order:'msb'
      }
    );
    
    var WAKEUP_PIN=D17;
    var SS_PIN=D18;
    var LOW=0;
    var HIGH=1
    
    var d=digitalWrite;
    function echo(){
        "compiled";
        d(SS_PIN, LOW);
        r=spi.send(0x55,SS_PIN);
        d(SS_PIN, HIGH);
    }
    
    // Send wake upfirst after giving Espruino time to load code.
    d(WAKEUP_PIN, HIGH);
    setTimeout(function(){  
      setTimeout(function(){
        d(WAKEUP_PIN, LOW);
        setTimeout(function(){
          d(WAKEUP_PIN, HIGH);
          setTimeout(function(){
            setInterval(function(){
              echo();
            },1000);
          },1000);
        },10);
      },1000);
    },2000);
    

    Here's the output...

    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v01 (c) 2018 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    >Setting up SPI
    echo response: 12
    echo response: 0
    echo response: 0
    echo response: 0
    echo response: 0
    echo response: 5
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 20
    echo response: 0
    echo response: 0
    echo response: 0
    echo response: 0
    echo response: 0
    echo response: 0
    echo response: 0
    echo response: 0
    echo response: 0
    echo response: 1
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 85
    echo response: 245
    echo response: 255
    echo response: 255
    [etc. ...]
    
About

Avatar for user97106 @user97106 started