How to use array variable for shiftout command


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: How to use array variable for shiftout command

    thanks for the info , as i did not know how to include a comma in that way

    perhaps its me who is not too clear on the shiftout command and how it works , but the way i read the command from the help is that items within the brackets [ ], separated by a comma are the bytes to be sent synchronously ,

    eg - shiftout , datapin , clockpin ,mode, [ byte(0) , byte(1), byte(2)]

    the number of bytes can be as many as required , but each byte hex value MUST have a comma separating them ,
    the waveform produced would generate the clock and bits data values for the number of the bytes shown

    after each byte processed within the command , will hold the clock pin low period 2 times longer than each clock tick width , then process the next byte , till all bytes are sent

    the waveform would have no breaks in time for the total of each bytes sent per command , register byte , data bytes
    i am not sure if that is important to other chips on the SPI bus as i thought it may be for it is looking for command , register , number of bytes in sync

    as such you would need to get the data you want to send as one complete string and then execute the command once.

    now if i loop the command such as

    for x to number_bytes
    shiftout , datapin , clockpin ,mode, [ data_out(x)]

    next x


    the resulting waveform will have a longer time between each byte processed as only 1 byte is sent per the command

    it is in effect sending command byte , then next loop , register byte , then next loop data byte(0) , etc

    if that is not a problem for any device on a SPI then all i need do is loop untill the number of bytes to be sent


    but i think you will see the differences in the resulting waveform between the 2 methods

    admittedly as write the explanation, i also solve the problem sometimes as well ,

    so will loop and see how it goes i think

    cheers

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: How to use array variable for shiftout command

    Hi,
    Yes, there will be a slight delay between bytes when using the loop method but since SPI is a synchronous bus I don't think it'll be a problem in real life. With that said I HAVE run into a device which had a minimum SPI clock frequency. In that particular case SHIFTOUT was too slow all together but if it had been just on the limit then something like this loop method MIGHT have messed with it. You'd need to scope the output to determine the actual delay and compare that to the datasheet of the device you're interfacing. I'd venture a bet that it'll work just fine.

    OK, got it regarding the commas, you didn't mean to actually send them out, you're just talking about the syntax of the SHIFTOUT command, thanks.

    /Henrik.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts