128bit Shiftout? how?


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2008
    Posts
    38

    Default 128bit Shiftout? how?

    Hi All,

    I need to send a 128bit word to control some external equipment.

    the equipment requires the 128bit word clocked into it, then a seperate pin is pulsed to 'store' that word, and repeated forever (as the 128bit word changes).

    Looking thru the shiftout command, i see it is limited to 8bit (or 16 bit words) that it will send out.

    If i shiftout my 128bit word as 16x (8bit)bytes (=128 bits in total) will that do anything weird to my 128bit word? such as adding pauses or delays etc?
    (or i could send 8x (16bit words) too).

    Of course there may be a better way to achieve this? anyone?

    thanx in advance,
    Marty.

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gtvmarty View Post
    Hi All,

    I need to send a 128bit word to control some external equipment.

    the equipment requires the 128bit word clocked into it, then a seperate pin is pulsed to 'store' that word, and repeated forever (as the 128bit word changes).

    Looking thru the shiftout command, i see it is limited to 8bit (or 16 bit words) that it will send out.

    If i shiftout my 128bit word as 16x (8bit)bytes (=128 bits in total) will that do anything weird to my 128bit word? such as adding pauses or delays etc?
    (or i could send 8x (16bit words) too).

    Of course there may be a better way to achieve this? anyone?

    thanx in advance,
    Marty.

    It shouldn't matter at all if you break it down into 16 bytes, you are using an 8-bit device anyway presumably so there isn't any other major option.

    There's a few ways, if you can use assembler then that will produce the shortest execution time for one loop, but might be unecessary.
    If you're using picbasic only, why not save your 16 bytes as an array...and rotate through them

    In pseudo-pseudocode

    Code:
    shift_reg var byte[16]
    ' the 16 bytes independently accesible via the array construct
    Code:
    loop_cnt var byte
    ' overall loop counter
    Code:
    for loop_cnt = 0 to 15
    
    shiftout shift_reg[loop_cnt]
    
    next
    
    toggle pulse I/O pin
    ....do something else here or loop back to the shiftout for-next loop

    Because you are using a shiftout I've assumed the device you are sending to will accept the synchronous condition, in other words it will work at whatever speed you happen to shift your data out at, and not load it's contol registers until after you have pulsed the I/O line and in this case the controlled device will not perceive any transmission speed errors even if you have varying duration wait periods between the sending of each byte.

    If the controlled device needs you to send a continuous stream within a fixed time period between the start and end of the transmission, with no gaps, then you may need to look to using a idfferent approach where you either write consecutive shiftout commands, or use and abuse some of the pic's communictions peripherals to do the sending for you, and while it is sending yoiu reload the buffer register behind the peripheral so that it can keep pumping out a continuous bitstream.

    Without knowing the communications protocol on the controlled device its not possible to say for sure which method is best suited for it. Does the controlled device have a datasheet, the clues are usually to be found there

Similar Threads

  1. 7 Segment Displays and MAX7219
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st October 2010, 18:30
  2. Using MAX 7221 LED driver
    By Nick in forum mel PIC BASIC
    Replies: 15
    Last Post: - 21st October 2010, 19:31
  3. Smart Star (how to use shift registers)
    By mackrackit in forum Code Examples
    Replies: 3
    Last Post: - 30th November 2008, 20:06
  4. PC Keyboard question
    By HatchetHand in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 18th September 2007, 06:03
  5. Shorter Subroutines for MAX7219
    By exelanoz in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th March 2007, 11:35

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