Announcement

Collapse
No announcement yet.

SPI connection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SPI connection

    I have some questions regarding the SPI connection for diablo16.
    For example, how I can configure my display? I want to be the "master" for requesting information, so how i can configure my display in "master"?
    I have already configured the pins MOSI, MISO, SCK and SS, with the respective PA (because I have the gen4), but the waves that are generated with the oscilloscope are not correct, because they do not arrive at a frequency set by the command SPI1_Init (speed, mode).

    Thank for your time.
    Eros

  • #2
    Hello Eros,

    The SPI on a Diablo is Master mode only so it will already be in master mode.

    Can you let me know how you are using the SPI1_Init command including the speed setting value entered. Is it one of the pre-defined speeds as shown on page 233 of this datsheet https://www.4dsystems.com.au/product...ions_R_2_0.pdf

    Best regards

    Paul

    Comment


    • #3
      Thank for the answer;

      Well, I use the gen4 for the connection with my display, I have configured in this way the SS, MOSI, MISO, SCK (following the datasheet of gen4):

      pin GPOI1 - PA3 - SCK
      pin GPIO2 - PA2 - SDI
      pin GPOI3 - PA1- SDO
      pin GPIO4 - PA0 - SS

      in the code i follow the example in datasheet:

      #CONST
      CS PA0
      SDO PA1
      SDI PA2
      SCK PA3
      #END
      .
      .
      .


      pin_HI(CS) ;
      pin_Set(PIN_OUT,CS);
      SPI1_Init(SPI_SPEED6, SPI8_MODE_2);
      SPI1_SDI_pin(SDI));
      SPI1_SCK_pin(SCK));
      SPI1_SDO_pin(SDO));
      var answer;

      repeat

      SPI1_Write(0x01); // Request
      answer:= SPI1_Read();


      forever


      I think the configuration is ok, but i'm not sure for the code.

      Thank for your time.



      Comment


      • #4
        Hello,

        Your configuration and code looks correct. Are you conecting to a specific device and if so what is the device as it may be that more needs to be sent or a SPI1_Write(0x00); is necessary for the device to transfer back a value.

        Best regards

        Paul

        Comment


        • #5
          Thank you pauleilio, but if you see the image, there is an error in the "SCK" wave.
          The CS wave (green wave) more less it's correct, but the SCK wave (pink wave) not working, because it has to give me a 16 bit signale; but in the image, the SCK mustnt give me the right signale.

          Thank you for your time.


          Attached Files

          Comment


          • #6
            Any news for the connection?

            Comment


            • #7
              Hi,

              Can you please let me know what device you are connecting to in case that is the reason for the SCK going low. SPI works very well normally. You could also move the Init after the pin definitios to see if that changes things.

              pin_HI(CS) ;
              pin_Set(PIN_OUT,CS);
              SPI1_SDI_pin(SDI));
              SPI1_SCK_pin(SCK));
              SPI1_SDO_pin(SDO));
              SPI1_Init(SPI_SPEED6, SPI8_MODE_2);

              Best regards

              Paul

              Comment


              • #8
                Thank you soo much, I hadn't enabled the CS in the other device, but now SPI connection work.
                I have the last question i promis ahah.

                Can I request information from other "CS"? Because i have other 3 devices to connect to the display. So just use the other GPOI pins, true?
                See the code example for the request and answer.

                #CONST
                CS1 PA0
                CS2 PA0
                CS3 PA0
                CS4 PA0
                SDO PA1
                SDI PA2
                SCK PA3
                #END
                .
                .
                .

                SPI1_Init(SPI_SPEED6, SPI8_MODE_2);
                SPI1_SDI_pin(SDI));
                SPI1_SCK_pin(SCK));
                SPI1_SDO_pin(SDO));


                repeat
                pin_Set(PIN_OUT,CS1);
                //request and answer

                pin_Set(PIN_OUT,CS2);
                //request and answer
                .
                .
                .
                forever



                Thank for your time.

                Comment


                • #9
                  yes, but dont forget to deassert the device before switching CS, otherwise both will get the data at same time if theyre sharing the same SPI bus

                  Comment

                  Working...
                  X