Shop OBEX P1 Docs P2 Docs Learn Events
sx28 code to sx48 code error — Parallax Forums

sx28 code to sx48 code error

datacpsdatacps Posts: 139
edited 2007-09-28 01:30 in General Discussion
I needed more ram to try to add features to my project and tried programing my sx48 with my sx28 code. I get a code3 exceed avaliable ram. What am I doing wrong...


these are my variables ? works with my sx 28

frequency······· VAR WORD
freqWanted······ VAR WORD
period·········· VAR WORD
periodMSBPlus1·· VAR BYTE
periodCntFrac··· VAR BYTE
optReg·········· VAR BYTE
tempW··········· VAR WORD ' Used by SetFreq, LCDStr, LCDWord
temp············ VAR BYTE ' Used by SetFreq, LCDChar, LCDStr
tempW2·········· VAR WORD ' Used by SetFreq
encoder1········ VAR BYTE
encoder1Last···· VAR BYTE
encoder2········ VAR BYTE
encoder2Last···· VAR BYTE

Comments

  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-09-13 07:11
    The SX 48 has less global memory, but twice the memoryspace. It's time to start using arrays to extent your global memory. There are many examples in the thread index



    <---Bill
  • datacpsdatacps Posts: 139
    edited 2007-09-14 00:05
    ···· Thanks Bill I saw·your other post but I hoped the global mem you spoke about was something different. According to the specs the sx 48 has almost 2 x times the Ram.·I am confused now as to Ram and global Mem. I guess I am better off with the SX 28 and using the arrays there. I guess it is time for me to learn how to write them. I have seen some great examples but I was hopeing the 48 gave me·twice the global mem·I was looking for. Thanks for your help...
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-09-14 05:28
    serial········ VAR·· Byte (16)············· '·Declares a 16 byte array
    txCount····· VAR··· serial(0)·············· ' Byte # 0
    txDivide····· VAR··· serial(1)·············· ' Byte #1
    txLo···········VAR··· serial(2)·············· ' Byte #2
    txHi············VAR··· serial(3)···············' Byte #3
    rxCount····· VAR···· serial(4)············· ' Byte #4
    rxDivide····· VAR··· serial(5)·············· ' Byte #5
    rxByte······· VAR··· serial(6)··············· ' Byte #6
    Here is a snippet from a Jon Williams code example, that I added the comments to.

    frequency··········· VAR··· WORD
    freqWanted········ VAR···· WORD
    period················· VAR··· WORD
    periodMSBPlus1·· VAR··· BYTE
    periodCntFrac······ VAR··· BYTE
    optReg················· VAR··· BYTE
    tempW················· VAR····WORD ' Used by SetFreq, LCDStr, LCDWord
    temp····················· VAR··· BYTE ' Used by SetFreq, LCDChar, LCDStr
    tempW2··············· VAR···· WORD ' Used by SetFreq
    encoder················ VAR··· BYTE (4)
    encoder1·············· VAR···· encoder(0)
    encoder1Last······· VAR···· ·encoder(1)
    encoder2·············· VAR···· encoder(2)
    encoder2Last········ VAR···· encoder(3)
    Try this, I'm not great at arrays, but I think it will work.


    Bill
  • BeanBean Posts: 8,129
    edited 2007-09-14 11:51
    datacps,
    The extra two ports (RD & RE) are located in the global memory area. So the SX48 has two less bytes of global memory.

    In many cases a byte variable can be replaced with BYTE(1) and be stored in the array memory area.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know what I know, don't confuse me with the facts...
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • datacpsdatacps Posts: 139
    edited 2007-09-28 01:30
    Thanks Bill,· and Bean· The array worked perfectly.· So i can now make the var byte into arrays to free up global ram..

    ·frequency······· VAR WORD
    freqWanted······ VAR WORD
    period·········· VAR WORD
    periodMSBPlus1·· VAR BYTE
    periodCntFrac··· VAR BYTE
    optReg·········· VAR BYTE
    tempW··········· VAR WORD ' Used by SetFreq, LCDStr, LCDWord
    temp············ VAR BYTE ' Used by SetFreq, LCDChar, LCDStr
    tempW2·········· VAR WORD ' Used by SetFreq
    encoder········· var byte(4)
    encoder1········ VAR ENCODER(0)
    encoder1Last···· VAR ENCODER(1)
    encoder2········ VAR ENCODER(2)
    encoder2Last···· VAR ENCODER(3)
    setrun·········· VAR BYTE
    ·
Sign In or Register to comment.