REXYGEN Community Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Login

    SPI communication in REXLANG

    Communication (RS232, RS485, I2C, SPI, UDP, TCP, ...)
    2
    4
    1.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      contactform
      last edited by

      Hello, I'm Tobby, the user of REXYGEN, trying building a project using raspberry pi via SPI to communicate with asic. I've programmed according to the example "0503-02_MCP3008_ADC", but it showed that openspi failed. I'm wondering why.

      0_1553193581047_OpenSPI_Fail.JPG

      Best Regards,
      Tobby Lin

      1 Reply Last reply Reply Quote 0
      • jaroslav_sobotaJ
        jaroslav_sobota
        last edited by

        Hi Tobby,
        did you enable SPI on your Raspberry Pi? Try running this in the Linux terminal:

        sudo ls /dev/spi*
        

        If you get "No such file or directory" response, SPI is not enabled. In such a case, you'll need to add the following to your /boot/config.txt:

        dtparam=spi=on
        

        Afterwards reboot your RPi and you should be up&running.

        Kind regards,
        Jaroslav

        1 Reply Last reply Reply Quote 0
        • C
          contactform
          last edited by

          Thanks ! It worked !
          other problems:

          1. How to assign a value to spi_bufTx[0] if I need SPI_MODE0 = 0 and MSBFIRST?
            ( spi_bufTx[0] = ___ ; //SPI data mode (0-3 mode, | 4=CS_HIGH | 8=LSB_FIRST | 16=3WIRE | 32=LOOP | 64=NO_CS | 128=READY) )
          2. Is there any time delay function in C file including in REXLANG?
          3. Can I decide the value of CS0 (GPIO8 of raspberry pi) by setting up CS0 =1 or 0 in C file?

          Best Regards,
          Tobby Lin

          1 Reply Last reply Reply Quote 0
          • jaroslav_sobotaJ
            jaroslav_sobota
            last edited by jaroslav_sobota

            Hi,

            1. In this case you just use
            spi_bufTx[0] = 0;
            

            If you wanted e.g. SPI_MODE = 2 and LSBFIRST, you would use

            spi_bufTx[0] = 2 | 8;
            

            In other words, the first 2 bits define mode, the 3rd bit defines CS behavior, the 4th defines LSB etc.

            1. CS signal is controlled by operating system. You can only change its behavior by the 3rd bit as mentioned above.

            As for the delay function, I have turned it into a separate topic.

            Best regards,
            Jaroslav

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            This is a community forum for REXYGEN users and fans. Detailed information can be found at REXYGEN homepage.

            There is also an outdated REXYGEN community forum.

            Powered by NodeBB.