Shop OBEX P1 Docs P2 Docs Learn Events
Pnut arrays GOT SERIAL TERMINAL DATA WORKING THANKS — Parallax Forums

Pnut arrays GOT SERIAL TERMINAL DATA WORKING THANKS

pilot0315pilot0315 Posts: 910
edited 2020-07-04 18:33 in Propeller 2
anybody
I have been working with gps asynchronous serial. Am able to get data but have difficulties with the arrays. Looked at several forum posts but cannot get a good handle on it.
Found this: https://forums.parallax.com/discussion/169784/pnut-arrays
and https://forums.parallax.com/discussion/167731/smart-pins-for-async-serial-for-p2-v27#latest
Used the tip from @Ariba
Can anyone please point me in a simple direction?

Thanks.
Martin
Attached are two of my crazy attempts.

Comments

  • I do have issues with the serial terminal ascii code. If I try to stabilize the screen the data now gets scrambled.

    Any Ideas??
  • You have gps_array and temp_array reserved before a couple longs -- could that be giving you grief?
  • @JonnyMac
    At this moment just trying to control the raw data and keep the screen from changing pages.
    I will be shortly attempting to filter out two strings then work them into arrays for further processing. Looked all over the forums for examples of arrays in P2 asm and have not found any thing that just covers arrays.
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-07-05 22:19
    [deleted]
  • Here's something you might want to try. See the section on register indirection in the P2 docs.
    .read           alts    index, #table
                    mov     value, 0-0
    
    
    .write          altd    index, #table
                    mov     0-0, value
    
  • @JonnyMac
    O.K. I will look.
    Thanks
  • JonnyMac wrote: »
    Here's something you might want to try. See the section on register indirection in the P2 docs.
    .read           alts    index, #table
                    mov     value, 0-0
    
    
    .write          altd    index, #table
                    mov     0-0, value
    

    Can you explain a bit more in plain english what is happening here please?
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-07-07 18:05
    You do have access to the P2 docs, right? That's where I found this. In the event you don't have these links bookmarked, please do it now. With every P2 session I open all three. The P2 is a big beast and there is a lot to learn.

    -- https://docs.google.com/document/d/1gn6oaT5Ib7CytvlZHacmrSbVBJsD9t_-kmvjd7nUR6o/edit# (P2 docs)
    -- https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/edit#heading=h.tvlmfmnx47dd (Spin2 docs)
    -- https://docs.google.com/spreadsheets/d/1_vJk-Ad569UMwgXTKTdfJkHYHpc1rZwxB-DcIiAZNdk/edit#gid=0 (P2 instructions)

    The alts instruction alters the S (source -- were we want to read from) field of the next instruction. By adding an index value to the address of (#) the table, you know where you want to read from. The 0-0 in the mov instruction is what some programmers use to indicate that this is self-modifying code -- that's the field that the alts instruction is modifying.

    The altd works in a similar manner, but modifies the D (destination -- were we want to write to) field.

    The screen cap shows what you're looking for in the P2 docs. It seems pretty straightforward -- but I haven't tested it myself.

    1920 x 1040 - 161K
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-07-07 18:18
    After a break I went back and read a bit more of that section -- found that you can access Nibs and Bytes, too. These instructions might be useful if your goal is to save characters extracted from GPS input.
    ALTSB   index,#base		'set next D field to base+index[10:2], next N to index[1:0]
    SETBYTE value			'set byte to value ('SETBYTE S/#' = 'SETBYTE 0,S/#,#0')
    
    ALTGB   index,#base		'set next S field to base+index[10:2], next N to index[1:0]
    GETBYTE value			'get byte into value ('GETBYTE D' = 'GETBYTE D,0,#0')
    
    Again -- this is from the P2 docs and I haven't tested.
  • @JonnyMac

    That is more clear. I have the docs but some of the explanations are very limited.
    Been sifting through the forums to glean more info. @evanh and a few others have a great help.
    Thanks for the help. I will work with this today and let you know. Your explanation was pretty good.
  • @JonnyMac

    Looking for an example of the above code can't find in forums directly. Do you have an example??
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-07-13 16:42
    Sorry, I don't -- I pulled that from the, ahem, sparse documentation. I'm progressing well on a task -- when I get that done I will see if I can write a bit of a demo that may help you. That said, I'm not exactly sure what you want. Is it the ability to write to and read from a byte array in P2ASM?
  • Yes,
    I have also been pouring over the p1 versions that I can find and trying them. Too many to count.
    Will be working on it today.
    Thanks
Sign In or Register to comment.