Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 22 of 22

Thread: BNO080 and Teensy 4.1 and SPI issue

  1. #1

    BNO080 and Teensy 4.1 and SPI issue

    I have studied all of the posts about 4.x and I2C here on the forum. I am seeing similar problems with SPI to those mentioned in posts that data back to the first of this year. The Adafruit 80 library and various init routines from various forks all are about the same, even the I2C versions are very like the SPI. I have tested the Ada beginSPI routine extensively. The init seems to work up to the point where the 80 sends out the two first packet sets. That appears to be all OK.

    PRINT Packet

    Header: FF FF FF FF Body: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF [Continued packet]

    Length:32767 Channel:255

    The recent tests are missing the second packet header and data, don't know why.
    But it here is what came back when it did come back:


    Header: 14 01 00 00 Body: 00 01 04 00 00 00 00 80 06 31 2E 30 2E 30 00
    02 Length:276 Channel:Command


    But, then the send packet command "CHANNEL_COMMAND, 2" fails to get the header which should have the chip ID info.

    Packet Empty
    Header: 00 00 00 00
    BNO080 over SPI not detected. Are you sure you have all 6 connections? Freezing...
    SPI Wait
    ....


    I have tested the T4 from 24 to 600mhz, added in short delays in the read packet routine suggested by those working the I2C. The only thing I have not tried is clock stretching. I have all the latest IDE material, installed in the last 2 days.

    Paul S indicates that he did some work on the fifo wire routines for T4, is there a possible problem in the SPI with T4? The extensive material in the T3.6>>T4 thread was instructive but has not lead to a solution.

    Any suggestions?

  2. #2
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,642
    @Mike Maurice
    Played around quite a bit with the BNO080 with I2C but don't remember trying it with SPI. Believe I used the Sparkfun BNO080 library as opposed to the Adafruit version. If I can find what I did with my BNO080 I will hook it up and give it a try tomorrow with SPI and let you know what I find unless you solved your issue.

  3. #3
    Correct me all to pieces, it's the SparkFun lib. SparkFun_BNO080_Arduino_Library.h

    In any event, further testing: there are delays in the spiWait routine that are cpu dependent. The counter is 8 bits and I have tested with 16 bits using 25000 instead of 120 or so. Results in no timeouts. Testing indicates counters of at least 1500 or so stops most timeout, but I got one that happened above that.
    The readpacket routine I changed to use the spiWait, instead of looking at the _int =LOW. Which would occur only once on entry. Now it waits for the INT.

    This all helped, but still not getting data from CHANNEL_CONTROL,2 which should return data.
    More later.

  4. #4
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,642
    @Mike Maurice - @KurtE

    I modified and hooked up my sparkfun BNO080 using SPI. I can confirm that for some reason its not working on a T4.1.

    As a quick test I hooked it up to a T3.6 and re-ran the SPI Example 1 - RotationVector.ino sketch and it worked immediately:
    Code:
    SPI Wait
    
    Header: 12 80 02 01 Body: 84 00 00 00 01 00 00 00 00 00 00 00 00 00 [Continued packet] 
    
     Length:18 Channel:Control
    
    SPI Wait
    
    Rotation vector enabled
    
    Output in form i, j, k, real, accuracy
    
    Doing other things
    
    Header: 44 00 02 02 Body: F8 04 03 02 98 A4 98 00 72 01 00 00 07 00 00 00 F8 00 01 02 96 A4 98 00 E6 00 00 00 04 00 00 00 F8 00 04 04 36 A3 98 00 Length:68 Channel:Control
    
    0.00,0.00,0.00,0.00,0.00,90.91Hz
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Header: 15 00 02 03 Body: FC 05 00 00 00 50 C3 00 00 00 00 00 00 00 00 00 00 Length:21 Channel:Control
    
    0.00,0.00,0.00,0.00,0.00,9.43Hz
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Header: 17 00 03 00 Body: FB 17 00 00 00 05 00 00 00 9B 00 1A FF D4 C7 A6 1E 45 21 Length:23 Channel:Sensor-report
    
    0.01,-0.01,-0.88,0.48,2.08,11.90Hz
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Header: 17 00 03 01 Body: FB 17 00 00 00 05 01 00 00 9B 00 1B FF D4 C7 A6 1E 46 21 Length:23 Channel:Sensor-report
    
    0.01,-0.01,-0.88,0.48,2.08,13.20Hz
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Header: 17 00 03 02 Body: FB 17 00 00 00 05 02 00 00 9B 00 1C FF D4 C7 A6 1E 46 21 Length:23 Channel:Sensor-report
    
    0.01,-0.01,-0.88,0.48,2.08,14.16Hz
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Header: 17 00 03 03 Body: FB 1B 00 00 00 05 03 00 00 9C 00 1C FF D4 C7 A6 1E 46 21 Length:23 Channel:Sensor-report
    
    0.01,-0.01,-0.88,0.48,2.08,14.85Hz
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Doing other things
    
    Header: 17 00 03 04 Body: FB 17 00 00 00 05 04 00 00 9C 00 1C FF D4 C7 A7 1E 46 21 Length:23 Channel:Sensor-report
    
    0.01,-0.01,-0.88,0.48,2.08,15.42Hz
    
    Doing other things
    
    Doing other things
    Think have to hook up the LA and see whats going on and maybe go through the code again.

  5. #5
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,692
    @mjs513 and @Mike...

    Might have to dig out BNO080... Test board I don't want to touch, but I think I have another one around here in my piles of piles...

  6. #6
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,692
    Morning again,

    Modified my BNO080 (newer one with qwiic). I soldered in headers and setup for SPI by breadboard 3.3v to PS0 and PS1 and then loaded their SPI version of the rotation vector...)

    And ran..

    Not sure what I am looking for...

    Code:
    SPI Wait
    SPI Wait
    SPI Wait
    SPI Wait
    SPI Wait
    SPI Wait
    SPI Wait
    Header: 14 00 02 00 Body: F1 00 84 00 00 00 01 00 00 00 00 00 00 00 00 00 Length:20 Channel:Control
    SPI Wait
    SPI Wait
    Header: 14 00 02 01 Body: F8 04 03 02 98 A4 98 00 72 01 00 00 07 00 00 00 Length:20 Channel:Control
    SW Version Major: 0x3 SW Version Minor: 0x2 SW Part Number: 0x98A498 SW Build Number: 0x172 SW Version Patch: 0x7
    SPI Wait
    Rotation vector enabled
    Output in form i, j, k, real, accuracy
    Doing other things
    Header: 23 80 02 03 Body: 00 04 04 36 A3 98 00 95 01 00 00 02 00 00 00 F8 00 04 02 E3 A2 98 00 D9 01 00 00 07 00 00 00 [Continued packet] 
     Length:35 Channel:Control
    0.00,0.00,0.00,0.00,0.00,100.00Hz
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Header: 15 00 02 04 Body: FC 05 00 00 00 50 C3 00 00 00 00 00 00 00 00 00 00 Length:21 Channel:Control
    0.00,0.00,0.00,0.00,0.00,9.52Hz
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Header: 17 00 03 00 Body: FB 17 00 00 00 05 00 00 00 F4 FF 3E 02 72 E0 A3 37 9D 17 Length:23 Channel:Sensor-report
    -0.00,0.04,-0.49,0.87,1.48,12.00Hz
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Header: 17 00 03 01 Body: FB 17 00 00 00 05 01 00 00 F4 FF 3E 02 72 E0 A2 37 83 12 Length:23 Channel:Sensor-report
    -0.00,0.04,-0.49,0.87,1.16,13.33Hz
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Header: 17 00 03 02 Body: FB 15 00 00 00 05 02 00 00 F4 FF 3E 02 71 E0 A2 37 83 12 Length:23 Channel:Sensor-report
    -0.00,0.04,-0.49,0.87,1.16,14.29Hz
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Header: 17 00 03 03 Body: FB 15 00 00 00 05 03 00 00 F4 FF 3E 02 71 E0 A2 37 84 12 Length:23 Channel:Sensor-report
    -0.00,0.04,-0.49,0.87,1.16,15.00Hz
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Header: 17 00 03 04 Body: FB 17 00 00 00 05 04 00 00 F4 FF 3E 02 71 E0 A2 37 84 12 Length:23 Channel:Sensor-report
    -0.00,0.04,-0.49,0.87,1.16,15.56Hz
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Doing other things
    Header: 17 00 03 05 Body: FB 17 00 00 00 05 05 00 00 F4 FF 3E 02 71 E0 A2 37 85 12 Length:23 Channel:Sensor-report
    -0.00,0.04,-0.49,0.87,1.16,16.00Hz
    Doing other things
    ...

  7. #7
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,642
    @Mike - @KurtE

    Ok may not have to. I pull out my LA and took a look at the output and was looking real strange on the T4.1. That made me go back and recheck the wiring from the BNO080. Looks like my bad again, had the jumper moved one pin over on the interrupt pin and then it started it working just like the T3.6.

    So conclusion issue may be on @Mike unit, wiring or initialization.

  8. #8
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,642
    @Mike
    Based on what I did lets take a look at your setup vs mine.

    1. can you tell us what BNO080 breakout board you are using?
    2. can you post a picture of your wiring?
    3. can you post your code you are using?

    My setup is currently using a Sparkfun BNO080 breakout board configured for SPI: https://www.sparkfun.com/products/14686 using their library: https://github.com/sparkfun/SparkFun...rduino_Library with the following hook up:
    Code:
      13 = BNO080 SCK
      12 = SO
      11 = SI
      10 = !CS
      9 = WAK
      8 = !INT
      7 = !RST
      3.3V = 3V3
      GND = GND
    The PS0 and PS1 jumpers on the Sparkfun board are closed inorder to put it into SPI mode.

  9. #9
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,642
    @KurtE
    Ooops - looks like we cross posted before I can tell you that it appears to be working in SPI mode

  10. #10
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,692
    Yep - Glad it is working for both of us.

    Note: I did not solder the jumpers on the board to configure for SPI, but used the breadboard pins to configure it into SPI mode.

    Also if it still does not work. I did an SPI Pull Request (maybe after the last Teensyduino was released) that fixed an issue when switching back and forth between transfer and transfer16. Don't know if they use transfer16 or not, but if you are still having problems, you should try pickin gup the latest version of SPI off of Paul's github... Likewise my Sparkfun library I just synced up to the latest stuff...

    Now back to pulling out hair with Bluetooth.

  11. #11
    The board is a FSM305 with the BNO080 chip on it. For some strange reason I did not get any of the notices on the 6th as emails, was not aware of these posts. I will double check all of the details, pins, etc.
    I am using the Sparkfun lib, latest from a few days(?) ago. THe init seems to happen. Two blocks of data get sent back, then the command to get the version information fails to return data. The sketch is the sample get Euler angles #17.
    The pins are:
    byte imuCSPin = 36;
    byte imuWAKPin = 41;
    byte imuINTPin = 5;
    byte imuRSTPin = 40;
    SPI = SPI, not SPI1


    More later.

  12. #12
    I may have the wrong SPI library in use.

  13. #13
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,642
    Quote Originally Posted by Mike Maurice View Post
    The board is a FSM305 with the BNO080 chip on it. For some strange reason I did not get any of the notices on the 6th as emails, was not aware of these posts. I will double check all of the details, pins, etc.
    I am using the Sparkfun lib, latest from a few days(?) ago. THe init seems to happen. Two blocks of data get sent back, then the command to get the version information fails to return data. The sketch is the sample get Euler angles #17.
    The pins are:
    byte imuCSPin = 36;
    byte imuWAKPin = 41;
    byte imuINTPin = 5;
    byte imuRSTPin = 40;
    SPI = SPI, not SPI1


    More later.
    If you look at figure 6 of the FSM305 datasheet (https://www.infinite-electronic.it/d.../ac-FSM305.pdf) and compare it to the Sparkfun BNO080 breakout board schematic (https://cdn.sparkfun.com/assets/5/c/...U_Breakout.pdf) it looks like you need do hook up;

    Code:
    PS1 -> 3.3v
    Then follow the connections in the example:
    Code:
      Arduino 13 = BNO080 SCK
      12 = SO
      11 = SI
      10 = !CS
      9 = WAK
      8 = !INT
      7 = !RST
      3.3V = 3V3
      GND = GND

  14. #14
    I have been gone for a week, just getting back to this. Your Pinouts are the same for 11,12,13 as we have our board. The PS1 is -> 3.3v. Your Pinouts for 7,8,9, 10 are different as we are using: 40,5, 41, 36. Are you saying that we must use the pinouts as you describe?

    I have installed the latest SPI library from: https://github.com/PaulStoffregen/SPI
    Regards,
    Mike

  15. #15
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,642
    I would recommend trying to change the CS pin from 36 to 10 and see if that works. Not sure about pin using pin 36.

  16. #16
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,692
    Might help to actually see what is hooked up to what?

    That is we know the Sparkfun works with SPI. But it looks like it is a different setup? This one? https://www.digikey.com/product-deta...005-ND/7917168

    From their document: https://www.ceva-dsp.com/wp-content/...-Datasheet.pdf

    Wondering for example what is connected to PS1 pin...

    Again my guess is it is a difference on what is needed to configure this chip/board to work using SPI.

  17. #17
    The change of pins from 36 to 10 did the trick. But, we are going to drop SPI and convert to I2C as the SPI timeout problem is too unstable for our purposes. And we don't need the SPI, so...
    Thanks for the suggestion. By the way, what was your reasoning for the change? The 10 pin is obviously part of the set of 10-13, but I was under the impression that the pin for CS was not critical. Oh, well.

  18. #18
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,642
    Re the CS pin change. Well the default CS pin for SPI is 10 and it was basically a hunch that pin 36 may not work automatically with the Lib. Was easier to suggest the pin change to see if it would work. @KurtE probably could explain more on this one.

  19. #19
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,692
    Quote Originally Posted by mjs513 View Post
    Re the CS pin change. Well the default CS pin for SPI is 10 and it was basically a hunch that pin 36 may not work automatically with the Lib. Was easier to suggest the pin change to see if it would work. @KurtE probably could explain more on this one.
    I have no idea! That is as far as I can tell, the sparkfun only does the cs support by using plain vanilla things like pinMode(_cs, OUTPUT); and digitalWrites();

    So my only guesses include
    a) It was not actually hooked up to pin 36, like it was off by one pin going to breadboard (been there, done that), or maybe bad connection, like bad solder joint or wire did not make good connection or...

    b) Some strange build setup, that is not using our normal Arduino IDE, with current builds, and maybe that pin was configured wrong.

    c) Or there is something screwy with pin 36..

  20. #20
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,642
    Quote Originally Posted by KurtE View Post
    I have no idea! That is as far as I can tell, the sparkfun only does the cs support by using plain vanilla things like pinMode(_cs, OUTPUT); and digitalWrites();

    So my only guesses include
    a) It was not actually hooked up to pin 36, like it was off by one pin going to breadboard (been there, done that), or maybe bad connection, like bad solder joint or wire did not make good connection or...

    b) Some strange build setup, that is not using our normal Arduino IDE, with current builds, and maybe that pin was configured wrong.

    c) Or there is something screwy with pin 36..
    Yeah - theres that too - just didn't know how to phrase it and still on first cup of coffee

  21. #21
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,692
    Morning @mjs513 - I am on my third half cup... It is late here almost 7AM...

    For what it is worth, I rehooked up my BNO080 using hardware jumper to choose SPI. and used default pins for all except CS and used pin 36
    Example17_EulerAngles...
    Again only changed: byte imuCSPin = 36;

    And I get output that I think is working:
    Code:
    SPI Wait
    SPI Wait
    SPI Wait
    SPI Wait
    SPI Wait
    SPI Wait
    Header: 14 00 02 00 Body: F1 00 84 00 00 00 01 00 00 00 00 00 00 00 00 00 Length:20 Channel:Control
    SPI Wait
    SPI Wait
    Header: 14 00 02 01 Body: F8 04 03 02 98 A4 98 00 72 01 00 00 07 00 00 00 Length:20 Channel:Control
    SW Version Major: 0x3 SW Version Minor: 0x2 SW Part Number: 0x98A498 SW Build Number: 0x172 SW Version Patch: 0x7
    SPI Wait
    Rotation vector enabled
    Output in form roll, pitch, yaw
    Header: 23 80 02 03 Body: 00 04 04 36 A3 98 00 95 01 00 00 02 00 00 00 F8 00 04 02 E3 A2 98 00 D9 01 00 00 07 00 00 00 [Continued packet] 
     Length:35 Channel:Control
    nan,nan,nan
    Header: 15 00 02 04 Body: FC 05 00 00 00 50 C3 00 00 00 00 00 00 00 00 00 00 Length:21 Channel:Control
    nan,nan,nan
    Header: 17 00 03 00 Body: FB 17 00 00 00 05 00 00 00 57 FF 05 FF B3 3B 08 17 8C 15 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 01 Body: FB 17 00 00 00 05 01 00 00 57 FF 05 FF B3 3B 08 17 5C 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 02 Body: FB 17 00 00 00 05 02 00 00 57 FF 05 FF B3 3B 08 17 5C 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 03 Body: FB 15 00 00 00 05 03 00 00 57 FF 06 FF B4 3B 07 17 5C 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 04 Body: FB 15 00 00 00 05 04 00 00 58 FF 06 FF B4 3B 07 17 5D 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 05 Body: FB 17 00 00 00 05 05 00 00 57 FF 06 FF B4 3B 07 17 5D 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 06 Body: FB 17 00 00 00 05 06 00 00 57 FF 05 FF B4 3B 07 17 5E 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 07 Body: FB 17 00 00 00 05 07 00 00 57 FF 05 FF B4 3B 07 17 5E 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 08 Body: FB 17 00 00 00 05 08 00 00 57 FF 04 FF B4 3B 07 17 5F 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 09 Body: FB 17 00 00 00 05 09 00 00 57 FF 04 FF B4 3B 07 17 5F 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 0A Body: FB 19 00 00 00 05 0A 00 00 57 FF 04 FF B4 3B 07 17 60 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 0B Body: FB 17 00 00 00 05 0B 00 00 57 FF 04 FF B4 3B 07 17 60 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 0C Body: FB 17 00 00 00 05 0C 00 00 58 FF 04 FF B4 3B 07 17 61 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 0D Body: FB 17 00 00 00 05 0D 00 00 58 FF 05 FF B4 3B 07 17 61 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 0E Body: FB 17 00 00 00 05 0E 00 00 58 FF 05 FF B4 3B 06 17 61 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 0F Body: FB 1B 00 00 00 05 0F 00 00 58 FF 05 FF B4 3B 06 17 62 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 10 Body: FB 17 00 00 00 05 10 00 00 58 FF 05 FF B4 3B 06 17 62 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    Header: 17 00 03 11 Body: FB 17 00 00 00 05 11 00 00 57 FF 06 FF B4 3B 06 17 63 12 Length:23 Channel:Sensor-report
    -2.1,0.5,137.8
    ...

  22. #22
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,588
    Thought I'd help beat the dead horse ... I hooked up Sparkfun BNO080 to T4.1 in SPI mode (PS0 and PS1 jumpered to 3v3) and ran the SPI EulerAngles example(17) and used pin 36 for CS. I commented out enableDebugging() so I could run the SerialPlotter and track roll, pitch, and yaw as I manipulated the IMU. Works for me.

    Click image for larger version. 

Name:	bno.jpg 
Views:	6 
Size:	26.8 KB 
ID:	21879
    Last edited by manitou; 09-28-2020 at 03:29 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •