Raspberry Pi - SPI (spidev) Communication with PLL

Discussion in 'Embedded Systems and Microcontrollers' started by Renegade243, Nov 25, 2015.

  1. Renegade243

    Thread Starter New Member

    Feb 5, 2013

    I am trying to program a PLL device with SPI on the RPI using spidev inside Python. I want to rewrite all the values inside the registers on the AD9553 device to allow for a very specific configuration. So far I have calculated all the necessary values to store in the registers for my specific configuration, I have kept these binary values in an array ready to send later. First an instruction bit must be sent to the device defining whether you would like to read or write and if you want to operate in streaming mode, in this case yes as I want to start from register 0x34 and end at 0x00 rewriting all registers in the process. The device should theoretically receive the 16 bit instruction command and then receive the successive 52 - 8 bit commands successively buffering them in the register, I then administer an I/O update in register 5 causing the registers to be loaded thus taking into effect. I am confident that these register values are correct.

    However I have some significant doubts:
    1) At the moment I am using "Xfer2()" to transfer the bytes from the PI to the device, I dont know if this is the correct command since there is write bytes and "Xfer()" as well.
    It seems the PI is transmitting from the MOSI pin this is connected to the SDIO pin on the AD9553, I am not completely sure how this works.
    3) I do not understand the syntax in Spidev I have read through the documentation and the code but it does not seem to clear up any doubts
    4) I am using a for loop in Python to transfer all the bytes from the Reg_Store array to the device (not sure if this is the correct approach)
    5) I am not sure what to set for the parameters of the SPI device i.e (threewire mode, max clock speed, etc)

    Methods I have approached
    1) Splitting up the instruction into two 8 bits and then sending all 52 register after (inside a for loop)
    2) Forcing the Chip Select to Low in the loop
    3) Messing around with spi.max_speed
    4) Trying to send the entire list of values in one line
    5) writebytes and xfer

    I have previously used Spidev to communicate with an ADC, however it was far easier as you just sent two bytes and then you would receive back the two bytes of information, like a shift register. This works so I know I do not have a problem with my Pi or the SPI.

    I am hoping someone with experience will be able to point out directly what I am doing wrong, I look forward to receiving replies. (Attached is the datasheet and one of the python code I have written)

    Many Thanks for reading this.