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

Thread: How to configure SPI1 on Tennsy3.6

Threaded View

  1. #1
    Junior Member
    Join Date
    Dec 2016
    Posts
    3

    How to configure SPI1 on Tennsy3.6

    Hello,
    I have problem how to configure SPI1 on Tennsy3.6? I try to connect to AD7175.
    Now I configure as below and then i check all pin in oscilloscope nothing happen.
    I test board is work on SPI0 connect to TCP module WIZ820io. Please help me about my mistake.( Thank you very much)

    #include <SPI.h>

    int slaveSelectPin = 31;
    #define ID 0x0CD9

    unsigned int regValue;

    void setup() {
    // put your setup code here, to run once:

    Serial.begin(9600);
    SPI1.setBitOrder(LSBFIRST);
    SPI1.setDataMode(SPI_MODE3);
    SPI1.setClockDivider(SPI_CLOCK_DIV16);
    SPI1.setSCK(32);
    SPI1.setMOSI(0);
    SPI1.setMISO(1);
    SPI1.setCS(31);
    SPI1.begin();
    pinMode(31,OUTPUT);
    pinMode(2,INPUT);
    }

    void loop()
    {

    //delayMicroseconds(1);
    SPI1.transfer(B01000111); // Bit 6 = 1 for read. Register 0x07 for ID register.
    //digitalWrite(slaveSelectPin,HIGH);

    digitalWrite(slaveSelectPin,LOW);
    delayMicroseconds(1);
    byte b1 = SPI1.transfer(0);
    byte b0 = SPI1.transfer(0);
    byte b2 = SPI1.transfer(0);
    digitalWrite(slaveSelectPin,HIGH);


    unsigned int result = b0 * 256 + b2;
    Serial.println(result, HEX);

    delay(1000);

    }
    Attached Files Attached Files

Posting Permissions

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