Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Memory Card — Parallax Forums

Propeller Memory Card

SELSEL Posts: 80
edited 2013-09-23 14:17 in General Discussion
I do not have the knowledge to modify the supplied object so that I may write and read LONG data.
I need to store and retrieve larger data type other byte.

Anyone who can help I really would appreciate it very much

Thank you,
Stan

Comments

  • kwinnkwinn Posts: 8,697
    edited 2013-09-20 18:14
    The chips used on this card are byte oriented. You can write longs by writing them 4 consecutive bytes.
  • SELSEL Posts: 80
    edited 2013-09-22 10:26
    Kwinn,

    When I contacted Tech Support and asked if they had a solution, they had none. They did not tell me about the chip byte orientation.
    This helps me to understand, a little, why i failed so badly.

    Would it be possible to get a code snippet on how you might approach this problem of writing and reading longs?

    No matter what I thank you very much!

    Stan
  • ElectrodudeElectrodude Posts: 1,658
    edited 2013-09-22 11:09
    Supposing you use the driver that came with the demo and are using SPIN and not C:

    Memory.readSRAM(memaddr, @yourlong, 4)

    Memory.writeSRAM(memaddr, @yourlong, 4)

    A long is just 4 bytes, so all you have to do is read or write 4 consecutive bytes and give the read or write function where in the SRAM your variable is (memaddr), a pointer to where your long is in HUBRAM (@yourlong), and 4 as the number of bytes to read.
  • Mike GMike G Posts: 2,702
    edited 2013-09-22 11:34
    As stated in posts #2 and #4, write 4 bytes to represent a long. Understanding the concept of Endianness which is explained in linked Wikipedia wiki will help,

    Also see the Propeller Manual and read about, byte, word, and long aligned/sized data,
  • SELSEL Posts: 80
    edited 2013-09-22 13:27
    I wish to thank all of you for you consideration and time!

    I will work on this and then report back.

    Warmest regards,
    Stan
  • SELSEL Posts: 80
    edited 2013-09-23 14:17
    I wish to thank those four individuals that took the time to help me.
    The snippet of code below is just for test and proving. It Works!
    I now will great an object to wrap the functions I will develop from this small start.


    MP := 0
    Index := 0
    Data := 1000

    Buffer.long[Index] := Data

    Memory.WriteFlash(MP, @Buffer, 4)

    MP := 4
    Index := 1
    Data := 2000

    Buffer.long[Index] := Data

    Memory.WriteFlash(MP, @Buffer, 4)

    Memory.ReadFlash(MP, @Buffer, -1)
    TransmitBuffer

    Data := Buffer.long[0]

    Term.str(string(CR))
    Term.str(string("Data = "))
    Term.dec(Data)
    Term.str(string(CR))

    Data := Buffer.long[1]

    Term.str(string(CR))
    Term.str(string("Data = "))
    Term.dec(Data)
    Term.str(string(CR))


    repeat

    PRI TransmitBuffer | Idx

    repeat Idx from 0 to 63
    ifnot Idx // 16
    Term.Char(CR)
    Term.Hex(Buffer.long[Idx], 4)
    Term.Char(" ")
    Term.Char(CR)
Sign In or Register to comment.