Shop OBEX P1 Docs P2 Docs Learn Events
Solved :) Data Block limits in Spin (More of an access issue I think) — Parallax Forums

Solved :) Data Block limits in Spin (More of an access issue I think)

PliersPliers Posts: 280
edited 2016-08-03 23:43 in Propeller 1
I seem to have hit a limit as to how to access bytes in the Data block.
I'm using the FullDuplexSerial to communicate with an XBee.
The Xbee on the receiving end sends the bytes to a text to speech module.
The original program is much more complex, but when I started having problems I simplified it for this conversation.
Hello1 thru Hello10 is all the same data as you can see. The speech module says "Hello".
I can play Hello1 thru Hello6 without a problem. When I try Hello7 or above, the communications fail. I'm certain has to do with the addressing because I was getting misplaced bytes on the receiving end.
CON
        _clkmode = xtal1 + pll16x   
        _xinfreq = 5_000_000
VAR
  byte temp
  byte x  ' Loop counter
  byte c  ' Bytes to send
  byte k  ' Data address
 
OBJ
  Serial : "FullDuplexSerial" 

PUB main
serial.Start(24, 25, %0000, 9_600)       'for the XBee  communications
waitcnt(cnt + 100000)
 k := @Hello2           'Anything above Hello6 does not work.
 C:=byte[k][0] 
 x:=1
  repeat C
     Temp := byte[k][x]
     serial.tx(Temp)
  x := x+1
repeat
        
DAT
Hello1         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 
Hello2         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 
Hello3         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 
Hello4         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 
Hello5         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 
Hello6         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 
Hello7         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 
Hello8         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 
Hello9         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 
Hello10        Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B 


Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-08-03 23:09
    If you use BST and view the compiler listing you can see what has been compiled and where (see attachment). So the data is there.

    btw - There are lots of optimizations you can make in Spin for example:
    serial.tx(byte[k][x++])
    or
    x += 1
    etc
    0110(003D) 0A          | 
    0111(003D) 8B          | 
    0112(003D) 28          | Hello7         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B
    0113(003D) 7E          | 
    0114(003E) 00          | 
    0115(003E) 24          | 
    0116(003E) 00          | 
    0117(003E) 01          | 
    0118(003F) 00          | 
    0119(003F) 00          | 
    011A(003F) 00          | 
    011B(003F) 00          | 
    011C(0040) 00          | 
    011D(0040) 00          | 
    011E(0040) 00          | 
    011F(0040) 00          | 
    0120(0041) 00          | 
    0121(0041) 6E          | 
    0122(0041) 34          | 
    0123(0041) 0D          | 
    0124(0042) 0A          | 
    0125(0042) 77          | 
    0126(0042) 32          | 
    0127(0042) 30          | 
    0128(0043) 30          | 
    0129(0043) 0D          | 
    012A(0043) 0A          | 
    012B(0043) 76          | 
    012C(0044) 31          | 
    012D(0044) 30          | 
    012E(0044) 0D          | 
    012F(0044) 0A          | 
    0130(0045) 53          | 
    0131(0045) 20          | 
    0132(0045) 48          | 
    0133(0045) 65          | 
    0134(0046) 6C          | 
    0135(0046) 6C          | 
    0136(0046) 6F          | 
    0137(0046) 2E          | 
    0138(0047) 0D          | 
    0139(0047) 0A          | 
    013A(0047) 8B          | 
    013B(0047) 28          | Hello8         Byte  40, $7E, $00, $24, $00, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $6E, $34, $0D, $0A, $77, $32, $30, $30, $0D, $0A, $76, $31, $30, $0D, $0A, $53, $20, $48, $65, $6C, $6C, $6F, $2E, $0D, $0A, $8B
    013C(0048) 7E          | 
    013D(0048) 00          | 
    
  • AribaAriba Posts: 2,690
    Make your Vars longs and not bytes and it will work :smile:

    Andy
  • Thanks for the quick reply.
    I don't write much code, so those optimizations get forgotten. All I want is my robot to talk.

    Back to the problem. What did I do wrong with the Data addressing?
  • Thanks Ariba, you saved me again.
  • AribaAriba Posts: 2,690
    edited 2016-08-03 23:48
    At a second look I see only k really needs to be a long or a word. But I always make single (scalare) global variables a long, these makes the least problems. And it's the natural size for a 32bit processor.

    For sure for arrays this is different. There you can save a lot of memory with byte or word arrays.

    Andy
Sign In or Register to comment.