November 22, 2024, 12:20:07 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


16 bit EEPROM data

Started by GOT, December 11, 2008, 09:31:07 PM

Previous topic - Next topic

GOT

I am trying to use a shift register (two ganged together, actually) to control 16 LED lights.  Everything works fine if I say something like:

string1 VAR WORD

string1 = %0101010000100010
  SHIFTOUT Dpin, Clock, MSBFIRST, [string1.BYTE1, string1.BYTE0]
     PULSOUT Latch, 1


But if I try a data table, I loose the last 8 bits (only the first 8 lights respond):

Pat1      DATA  WORD    %0000000000000001, %0000000000000010, %0000000000000100, %0000000000001000
      DATA   WORD   %0000000000010000, %0000000000100000, %0000000001000000, %0000000010000000
      DATA   WORD   %0000000100000000, %0000001000000000, %0000010000000000, %0000100000000000
      DATA   WORD   %0001000000000000, %0010000000000000, %0100000000000000, %1000000000000000
           

FOR tick = 0 TO 15
   READ (Pat1 + tick), string1
   SHIFTOUT Dpin, Clock, MSBFIRST, [string1.BYTE1, string1.BYTE0]
       PULSOUT Latch, 1
   PAUSE 100
NEXT

I am assuming the EEPROM data can hold only the first 8 bits.  Am I right or am setting up the data table wrong?

BigRez

December 11, 2008, 10:01:54 PM #1 Last Edit: December 11, 2008, 10:03:33 PM by bigrez
The EEPROM can hold the full 16 bytes.  I think part of the problem is that you must prefix each value with the WORD modifier as in:

Pat1    DATA WORD %0000000000000001, WORD %0000000000000010
           DATA WORD %0000000000000100, WORD %0000000000001000
           DATA WORD %0000000000010000, WORD %0000000000100000
           DATA WORD %0000000001000000, WORD %0000000010000000
           DATA WORD %0000000100000000, WORD %0000001000000000
           DATA WORD %0000010000000000, WORD %0000100000000000
           DATA WORD %0001000000000000, WORD %0010000000000000
           DATA WORD %0100000000000000, WORD %1000000000000000

Then your READ statement must also use the WORD modifier as in:

READ (Pat1 + tick), WORD string1

I don't have a prop-2 (yet) to test this on though... :)

JonnyMac

December 11, 2008, 11:37:17 PM #2 Last Edit: December 11, 2008, 11:41:09 PM by JonnyMac
You got that table part right, BigRez, but you need to modify the READ statement like this:

  READ Pat1 + (tick * 2), Word string1

We need to multiply tick by two to account for the two-byte (word) values in the table.

In the FWIW category, that particular sequence doesn't require a table.  It can be coded as follows.:

Zip:
  FOR idx = 0 TO 15
    string1 = 1 << idx
    SHIFTOUT Dpin, Clock, MSBFIRST, [string1.BYTE1, string1.BYTE0]
    PULSOUT Latch, 1
    PAUSE 100   
  NEXT
Jon McPhalen
EFX-TEK Hollywood Office