Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Generating SPI Communication without a Driver

  • bwayt - 2021-08-24

    Hello all,
    I am trying to initiate SPI communication with a LS3667R buffer board (https://lsicsi.com/datasheets/LS7366R.pdf). Following suggestions for my previous post (https://forge.codesys.com/forge/talk/Runtime/thread/80ca780e26/?limit=25#7ed3/bb06), I decided to execute SPI communication directly in my PLC_PRG with a call to a "read" and "write" method; these methods in turn (ideally) start SPI communication using

    SPI_master.transferExt(pabyTxBuffer, pabyRxBuffer, udiLen, uiDelayus, udiSpeedHz)

    Putting a scope on the RPi4's MOSI and SCLK lines shows nothing. Am I way off in my approach?

  • h-hermsen

    h-hermsen - 2021-08-24

    maybe this topic provides you some extra help?


    plus don't forget to enable SPI interface via sudo raspi-config but you have probably done this ;-)


    Last edit: h-hermsen 2021-08-24
    • bwayt - 2021-08-25

      (SPI is enabled on the RPi)
      I took a look at that link and gave it a try, creating a class that extended SPI.
      It seems that CODESYS wants BeforeWriteOutputs, AfterReadInputs, and Initialize to be overloaded with a call to SUPER. Wouldn't that mean I'd also have to write the .xml file? Is there any way to get around this?

  • eschwellinger

    eschwellinger - 2021-08-26

    check this example here:
    c:\Users\yourWindowsUsername\CODESYS Control for Raspberry PI\\Examples\PiFace_FB.project
    this example should show how TO use a SPI device from your project without having a library.
    Do not forget to reduce SPI diMaxSpeed,
    this leads sometimes to problems.


    Last edit: eschwellinger 2021-08-26
    • bwayt - 2021-08-26

      I'd like to ask about that last part. Why do we specify speed in the SPI_master options when we have to specify it anyway when we call .transferExt?


Log in to post a comment.