No announcement yet.

Odd failures with SPI device, the P1-01AC, and base controller

  • Filter
  • Time
  • Show
Clear All
new posts

  • Odd failures with SPI device, the P1-01AC, and base controller

    Hey all,

    I have a Adafruit MAX31856 (Thermocouple) as the only device on the SPI bus via the official proto board. The CS is connected to pin 7 (not A3 and A4). When I power the system via USB, the SPI device works as intended as the read temp is displayed on a 7 segment LED. This system drives three relays on the P1-08TRS module.

    Case 1: Works
    Power the system via the P1-01AC PS
    Do NOT init base controller chip (via P1.init() )

    Case 2: The TC doesn't work (but the rest of the system does)
    Power the system via the P1-01AC
    Init the base controller

    I haven't thrown the analyzer on this yet because I must be doing something stupid.

    Any ideas?!?

  • #2
    Could you post your code. An attachment or gist link is best.


    • #3
      Yep, here is the code. I didn't squeeze it down, sorry.
      Attached Files


      • #4
        I think your issue is with this line
        Adafruit_MAX31856 TC_device = Adafruit_MAX31856(P1AM_MAX31856_CS, P1AM_MOSI, P1AM_MISO, P1AM_SCK);          // combo thermocouple amp and ADC
        I'm fairly certain your fix will be changing it to this:
        Adafruit_MAX31856 TC_device = Adafruit_MAX31856(P1AM_MAX31856_CS);          // combo thermocouple amp and ADC
        It looks like this library has an unusual feature where you can choose to bit-bang SPI through GPIO. For the unfamiliar that means you are quickly toggling GPIO pins to emulate a SPI bus. Passing in all 4 pin parameters for your MAX31856 class uses this bit-banging method. What's happening, is when you call P1.init() afterwards, those pins are re-defined from GPIO to hardware SPI pins. This makes the underlying bit-bang functions stop working as the pins have been re-configured. If you create your class instance with just a CS pin, it defaults to true SPI behaviour.



        • #5
          Nailed it!

          Great system by the way. Hope to install a bunch of these for various projects!!


          • #6
            Thanks a lot! What kind of project are you doing with this code?