Shop OBEX P1 Docs P2 Docs Learn Events
BeauNET with PropBASIC - I'm stuck! — Parallax Forums

BeauNET with PropBASIC - I'm stuck!

simonlsimonl Posts: 866
edited 2010-04-07 16:53 in Propeller 1
I've probably bitten-off more than I can chew here (wouldn't be the first time), but I thought I'd try to get Beau Schwabe's high-speed comm's (8.42M Baud) to work with PropBASIC. Unfortunately, whilst I've got it to compile and download to the Prop (RX portion only at the mo'), after the initial texts all I see is garbage.

I hope it's something simple (and I'll continue to look at this myself), but wondered if anyone else might be able to spot what I've done wrong (see attached)?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon

www.norfolkhelicopterclub.com

Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

Comments

  • BeanBean Posts: 8,129
    edited 2010-04-06 16:42
    I think I see the problem.
    Change the beginning of the routine to this(below) and see if that works.
      RX_Propeller_COM        org
          mov       DataSamples,            PacketSize
     
          mov       DataIndex,              DataIn_ofs        'Read Data Location into DataIndex
    
          add       DataIndex,              par
     
          mov       RX_PinMask,             #1         'Create Pin Mask for Input/Output pin
          shl       RX_PinMask,             #RX_Pin_No
    
    

    · What is happening is that the "DataSamples VAR LONG = PacketSize" is setting DataSamples to the address of "PacketSize" not the value contained in "PacketSize". This is a bug in PropBASIC that I'll have to fix. Any constant > 511 will have this problem (because they are declared as a VAR LONG instead of in the CON section. Adding the line "mov DataSamples, PackSize" should fix it.

    · In PropBASIC "par" holds the address of the start of the HUB variables. You need to add the offset to "par" to point to a particular hub variable. It just so happens that "DataIn_ofs" is zero, so your old code would have worked but just by luck.

    · Let me know if it works.
    ·
    Bean


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.
    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There are two rules in life:
    · 1) Never divulge all information
  • simonlsimonl Posts: 866
    edited 2010-04-06 16:43
    Hmmm, looks like it might be something to do with the sending of a number as an ASCII string:

            STR ascii, OldError, 6
            SENDSTR ascii
    
    
    SUB SendChar
        SEROUT DiagTX, Baud, __param1
    ENDSUB
    
    SUB SendStr
        __param2 = __param1 ' SendChar uses __param1
        DO
            RDBYTE __param2, __param3
            IF __param3 = 0 THEN EXIT
            SendChar __param3
            INC __param2
        LOOP
        SendChar 13
    ENDSUB
    
    



    SendChar and SendStr are from some example code, and the STR statement is part of PropBASIC.

    I'm still stuck!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • simonlsimonl Posts: 866
    edited 2010-04-06 16:44
    @Bean: Our posts crossed. I'll take a look at your suggestion just as soon as I've finished washing the dishes!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • BeanBean Posts: 8,129
    edited 2010-04-06 17:07
    Oh, yeah. That part won't work either.

    To use SENDSTR only works with HUB variables. So make ASCII a HUB BYTE(8) variable. And you also need to set the last character to zero so the SENDSTR routine will terminate.

    ascii HUB BYTE (9) ' Extra byte for the zero termination byte
     
                STR ascii, Match, 8 ' ascii(0..7)
                WRBYTE ascii(8), 0  ' Set zero terminator byte
                SENDSTR ascii
    
    


    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.
    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134

    March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There are two rules in life:
    · 1) Never divulge all information
  • simonlsimonl Posts: 866
    edited 2010-04-06 17:44
    Thanks for your help Bean, Unfortunately it's still not working - I still get garbage.

    I'm trying to break the problem down, so I've created this test prog' to see if I can get numbers output to the terminal:

    ' ----------------------------------------------------------------------
    ' Device Settings
    ' ----------------------------------------------------------------------
    DEVICE          P8X32A, XTAL2, PLL8X
    XIN             10_000_000
    
    
    ' ----------------------------------------------------------------------
    ' Constants
    ' ----------------------------------------------------------------------
        DiagTX      CON 30                              ' Diagnostic TX pin.
        DiagRX      CON 31                              ' Diagnostic RX pin.
        Baud        CON "T115200"
        CLS         CON 16
    
    ' ----------------------------------------------------------------------
    ' Shared (hub) Variables (Byte, Word, Long)
    ' ----------------------------------------------------------------------
    ascii       VAR LONG ( 9 )
    
    ' ----------------------------------------------------------------------
    ' Cog Variables (Long only)
    ' ----------------------------------------------------------------------
        OldError            VAR LONG = -1
        temp                VAR LONG = 0
    
    
    ' ----------------------------------------------------------------------
    ' SUB/FUNC Definitions
    ' ----------------------------------------------------------------------
        SENDCHAR    SUB 1
        SENDSTR     SUB 1
    
    
    ' ======================================================================
      PROGRAM Start
    ' ======================================================================
    
    Start:
        PAUSE 3000
        SENDCHAR CLS                                    ' Clear terminal screen.
        SENDSTR "Please press ENTER"
    
        ' Wait for user to press ENTER
        DO
            SERIN DiagRX, Baud, temp
        LOOP UNTIL temp = 13
    
        SENDCHAR CLS                                    ' Clear terminal screen.
        SENDSTR "Testing..."
    
    Main:
    
        DO
            INC OldError
    
            STR ascii, OldError, 6, 3
            WRBYTE ascii(8), 0
            SENDSTR ascii
    
            SENDCHAR "."
    '        PAUSE 250
    
        LOOP
    
        GOTO Main
    END
    
    
    ' ----------------------------------------------------------------------
    ' SUB/FUNC Code
    ' ----------------------------------------------------------------------
    SUB SendChar
        SEROUT DiagTX, Baud, __param1
    ENDSUB
    
    SUB SendStr
        __param2 = __param1 ' SendChar uses __param1
        DO
            RDBYTE __param2, __param3
            IF __param3 = 0 THEN EXIT
            SendChar __param3
            INC __param2
        LOOP
        SendChar 13
    ENDSUB
    
    



    With this; the screen clears (after I've hit ENTER) but then I just see the dots - one per line.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • simonlsimonl Posts: 866
    edited 2010-04-06 17:48
    Darn - scratch that last post; I'd not set "ascii HUB BYTE (9)" blush.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • simonlsimonl Posts: 866
    edited 2010-04-06 19:26
    Well; some progress - with your help I've got the SENDSTR to output numbers as ASCII - thank you.

    I implemented this and your suggestions into the original code (BeauNET_Demo_RX.pbas), but I still get garbage. I've even tried changing the "DataSamples VAR LONG = PacketSize" to "DataSamples CON PacketSize" (as it's a constant anyway, I think); whilst the garbage hasn't gone, it does at least change! I wonder if the garbage is an indication of my code still pointing to the wrong part of memory?

    I've attached my code and Beau's original codes so anyone can see how far I've got - I'm really struggling with this now.

    BTW: I have two Prop's connected; one has the original TX code (TX_Propeller_COM_PST.spin) and the second has my PropBASIC RX code (BeauNET_Demo_RX.pbas). The latter is supposed to be a PropBASIC version of RX_Propeller_COM_PST.spin.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

    Post Edited (simonl) : 4/6/2010 7:31:21 PM GMT
  • simonlsimonl Posts: 866
    edited 2010-04-06 20:06
    @Bean: Having re-read your first post, I figured I'd reduce PacketSize (to 256) and commented-out the mov:

    TASK BeauNET_RX
    
        ASM
            RX_Propeller_COM        org
    '                  mov       DataSamples,            PacketSize
                      mov       DataIndex,              DataIn_ofs  ' Read Data Location into DataIndex
    
    


    This has resulted in constantly repeating garbage (hey, that must be progress, right? LOL)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • simonlsimonl Posts: 866
    edited 2010-04-07 02:25
    Not sure if it's related to this "garbage" problem, but I'm just wondering if PropBASIC's "RANDOM var" is the same as Spin's "?var" ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-04-07 04:00
    simonl,

    Sorry I haven't replied sooner, I have been tied up with PropII layout ... your latest code you posted works fine. The only problem is that you are not waiting long enough between transmissions. Please read the note I placed at the waitcnt(800_000+cnt)

    The Attached code is basically the code that you posted.
    1) I modified it for 5MHz operation and moved the TX and RX pins to Pin 7 for both RX and TX
    2) I reduced the Debug baud to 19200
    3) On the waitcnt note above I placed it in a repeat loop of 3, so effectively it 'could' read...

    waitcnt(2_400_000+cnt)

    Note: Steps 1&2 above were just to make your code friendly to what I had setup, #3 is what the real culprit was.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • simonlsimonl Posts: 866
    edited 2010-04-07 11:45
    Hi Beau,

    Ah - crossed wires I think; I attached those two files so that others could see the original codes ( which work just fine smile.gif ). I'm actually trying to get them working in PropBASIC, but without much luck yet.

    My set-up has two Prop's; the first is running your TX code, but the second is running "BeauNET_Demo_RX.pbas" (which is my attempt to get your RX code to work in PropBASIC). The two are on the same breadboard with a 10K pull-down resistor on the comm's line. This set-up works fine with your code.

    I think the problem is related to pointing at the wrong place in memory, but I don't understand PASM nor PropBASIC enough to figure it out yet.

    Thanks for your post though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-04-07 16:53
    simonl,

    Hmmm, Sorry I don't know, PropBASIC is unfamiliar water for me.

    First thing I would do it to try to look at the 'garbage' at a bit level and check if maybe there isn't something weird like a data inversion or something. Set your data so that it would make a 'specific' pattern instead of the pseudo random seed... make sure that works first, and then expand your parameters.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
Sign In or Register to comment.