Post Go back to editing

ADAR1000 SPI

 Hello, I am using ADAR1000 but unfortunately, there is no reference source code. I could not find anywhere. Just we have SPI PROGRAMMING EXAMPLE in the Datasheet. I want to make and control the SPI communication protocol without using GUI. Can you provide example source code?

Best Regards.

Parents Reply
  • A few things:

    • You need to clock in the 16 preceding address bits, so you need to change the range function
    • You also need to keep the CSB high, unless you are writing bits to the SPI

    So, I think you'd want to change the tfr_byte2() to something like this (changed in bold):

    def tfr_byte2(data):

        GPIO.output(CSB, false)  #Pull the CSB low to enable the SPI port
        for i in range (0,24):
            GPIO.output(DATA, data & 0x01)
            pulseHigh(W_CLK)
            data=data>>1
        GPIO.output(CSB, true)  #Pull the CSB high to disable the SPI port

         return

    You will need to take care of the CSB-to-GPIO pin number mapping in your code.

    Also, in your initialization code of the GPIO lines, you'll want to start the CSB pulled high with:

    #Initialization Code

    GPIO.output(CSB, true)  #Pull the CSB high to disable the SPI port

    No guarantees that this works, but it should give you a pretty good start.  Hope this helps.

Children