Shop OBEX P1 Docs P2 Docs Learn Events
Memory Issue — Parallax Forums

Memory Issue

DragonRaider5DragonRaider5 Posts: 13
edited 2016-02-12 12:18 in Propeller 1
Hi,
I have a problem using some memory in the HUB RAM from different COGs. I'm relatively new to SPIN and PASM so I'm sorry if the mistake I made is stupid ^^ here is an example of what I'm doing(and what doesnt work):

main.spin:
OBJ
  test:  "test.spin"
  com: "Full-Duplex_COMEngine.spin"

PUB main | pointer
  test.writeToBuffer
  pointer := test.getBufferPointer              'ignore the fact that it takes some time to start the cog and to write the byte in the "new" cog as this is just an abstracted example :P
  com.writeByte(pointer.byte[0])

test.spin:
VAR
  long buffer[1]

DAT
                     org            0
  
WRB_start      mov           bufferPointer,            par
                     mov           tmp,                          #%0100_0001     '65
                     wrbyte       tmp,                          bufferPointer

                     cogid         tmp
                     cogstop     tmp

tmp               res             1
bufferPointer res             1

PUB writeToBuffer
  cognew(@WRB_start, @buffer)

PUB getBufferPointer
  return @buffer

The result is, that some random stuff gets written to the Serial Port but not the value I'm looking for("A", which equals 65). I also checked my function which converts the values which are meant to be displayed(in my real program) but it seems to work properly.

Thanks in advance and if you need any additional information don't bother asking me :)

PS.: Sorry for the bad formatting. Idk how to do it better in this editor :P

Comments

  • AribaAriba Posts: 2,690
    edited 2016-02-12 16:48
    com.writeByte(pointer.byte[0])
    
    This will send the low byte of the pointer (address of buffer) and not the first byte in the buffer.

    Try this:
    com.writeByte(byte[pointer][0])
    

    Andy
  • Hey Andy,
    thanks a lot! What a mistake hahaha I'll learn from it :) have a nice day!

    DragonRaider5
Sign In or Register to comment.