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;
The code is just for test to see if I can get consistent communications going.
I'm sending 0x55 (85) because the BM019 documentation says this should just echo back 0x55.
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.
I've checked my wiring loads of times and haven't spotted anything wrong there.
It seems odd that I sometimes get a 0x55 response, which is why I suspected a timing issue.
The BM019 documentation says I have to do a wake-up pulse so that' what I do first.
I am using software SPI here, but I find the same result on hardware SPI.
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);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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;
If anyone has any suggestions they will be most grateful received :-)
Here's the code...
Here's the output...