Shop OBEX P1 Docs P2 Docs Learn Events
LMM P2 Debugger - Uses Serial Tx & Rx for debugging single cog programs - Page 3 — Parallax Forums

LMM P2 Debugger - Uses Serial Tx & Rx for debugging single cog programs

1356710

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-03 22:01
    Sorry. v0.43 is the last posted code. v0.44 is the one I am about to work on next.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-10 19:32
    Hi Cluso.

    How I can modify Yours LMM RX routine to have "waitio" only flag without waiting to sample Character
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-10 20:27
    Sapieha,
    _HubRx                                                  '                       <--- receive character --->
    {{-----
    _HubRx
    ' On Entry:
     lmm_x = -anything-    '   value
     lmm_y = -not used-    '   mode
    ' Call Format:
    '        'FCALL SP++, @_HubRx   ' \   < call: receive char>
       wrlong  lmm_pc, lmm_sp   ' | PUSH PC
       add  lmm_sp, #4   ' | SP++
       rdlong  lmm_pc, lmm_pc   ' | CALL...
       long  @_HubRx   ' / ...PC = ADDR
    ' On Return:
     lmm_x = char     '   value
     lmm_y = -same-     '   mode (unchanged)
    -----}}
    :wait1          getp    #_rxpin                 wc      ' ensure stop/idle
            if_nc   sub     lmm_pc, #(($+1)-:wait1)*4       '> br back  (not stop/idle)
    :wait0          getp    #_rxpin                 wc      ' wait for start                \ start =0 edge 
            if_c    sub     lmm_pc, #(($+1)-:wait0)*4       '> br back  (stop/idle)         /
                    getcnt  lmm_w                           ' get initial time              \ setup 0.5 bit time
                    mov     lmm_x, lmm_bittime              ' bit period                    |
                    shr     lmm_x, #1                       ' 0.5 bit period                |
                    add     lmm_w, lmm_x                    ' add 0.5 bit period to time    |
                    waitcnt lmm_w, lmm_bittime              ' center of start bit           /
                    getp    #_rxpin                 wc      ' check start bit =0            \ verify start =0
            if_c    sub     lmm_pc, #(($+1)-:wait1)*4       '> br back  (invalid)           /
                    mov     lmm_x, #0                       ' clear char
                    waitcnt lmm_w,lmm_bittime               ' wait until bit period elapsed /
                    getp    #_rxpin                 wc      ' rx pin into c                 \ b0
                    rcr     lmm_x, #1                       ' accumulate bit                |
                    waitcnt lmm_w,lmm_bittime               ' wait until bit period elapsed /
    
    
    I think this is what you will need to do...
    Your user code will then need to look for the beginning of the start bit and immediately call _RX routine
    _HubRx                                                  '                       <--- receive character --->
    {{ returns lmm_x = -1  if no character or invalid }}
    {{ presume we have already detected the commencement of the start bit }}
                    getcnt  lmm_w                           ' get initial time              \ setup 0.5 bit time
                    mov     lmm_x, lmm_bittime              ' bit period                    |
                    shr     lmm_x, #1                       ' 0.5 bit period                |
                    add     lmm_w, lmm_x                    ' add 0.5 bit period to time    |
                    waitcnt lmm_w, lmm_bittime              ' center of start bit           /
    
                    getp    #_rxpin                 wc      ' check start bit =0            \ verify start =0
            if_c    sub     lmm_pc, #(($+1)-:wait1)*4       '> br back  (invalid)           /
                    mov     lmm_x, #0                       ' clear char
                    waitcnt lmm_w,lmm_bittime               ' wait until bit period elapsed /
                    getp    #_rxpin                 wc      ' rx pin into c                 \ b0
                    rcr     lmm_x, #1                       ' accumulate bit                |
                    waitcnt lmm_w,lmm_bittime               ' wait until bit period elapsed /
    .... existing code here (don't forget to check the stop bit and where it goes to if invalid...
    
                    add     lmm_pc, #4                  ' skip next instr if valid char in lmm_x
    invalid
                    sub     lmm_x ,#1                     ' make -1
    
    done      'here when all done or invalid
    '        'JFWD @_HubReturn   ' \   <jump fwd>
       rdlong  lmm_pc, lmm_pc   ' | JUMP...
       long  @_HubReturn   ' / ...PC = ADDR <returns to calling routine>
    '------------------------------------------------------------------------------
    
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-10 20:48
    Hi Cluso.

    Thanks.

    Will see If I can manage that changes to Yours LMM.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-13 00:05
    Hi Cluso.

    Cluso.
    It is possible You can add that type display of one LONG

    0AF- 000011 000 1 CCCC 1FF 1FF

    Then I can use my break to IN Real values display that POSITION in COG to see how that long have be modified

    tst1        add        xxx,yyy        Wz,Wc
    tst2        cmp        xxx,yyy        Wz,Wc
    
            jmp        ENDS
    
            xxx
            ...
            ...
    
    ''p2load -b 115200 -v -s LSD_043_Chj.obj -h -T
    ''---END-----------------------------------------
    ENDS        setp    #led17    
        if_z    setp    #led15    
        if_c    setp    #led16    
    ''        ==============
            JMP    #UserC                    'Jump to LMM Code
    ''===============================================
    
    
    ''---- Display Long
    
    USERC
    ' HEX REVERSED
                    mov     lmm_x, #$0D                     '\ <cr>
                    call    #LmmTx          wz,wc           '/ call LmmTx routine (saves and restores Z & C flags)
    ''===============================================================================================================
    ''                mov     lmm_y, #_XXX+_XXX+0        '\ set hex rev mode with 8 digits (8=0=default)
                        ''                mov     lmm_y, #_HEX+_REV+0        '\ set hex rev mode with 8 digits (8=0=default)
    ''                mov     lmm_x,temp                      '| load some 32bit value
    ''                call    #LmmFun         wz,wc           '/ call LmmFun  routine (saves and restores Z & C flags)
    
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-13 00:52
    Sure Sapieha.
    How do you want to get the cog address in there?

    Postedit
    Would you like it to be an option for the DUMP command? (use _CODE option) We already have _COG/_HUB so we could dump hub LMM too.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-13 03:05
    Hi Cluso.

    It can be DUMP -- One long at time.

    jmp ENDS

    Every time I place that (jmp ENDS) break address I recompile and reload.
    And after it run I check what happens in that parts code and its variables

    Addresses that I'm interested of -- I find by look in CTRL-L option in PNut
    Cluso99 wrote: »
    Sure Sapieha.
    How do you want to get the cog address in there?

    Postedit
    Would you like it to be an option for the DUMP command? (use _CODE option) We already have _COG/_HUB so we could dump hub LMM too.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-13 10:17
    Sapieha: Not quite sure if this is what you are after...

    I have added the mode #_DUMP+_COG+_CODE
    There are 2 calls in the sample part of the program (lmm_x is the cog address and lmm_y is the mode - they are both sticky with the address incrementing). I have not done hub mode for this yet. I have just coded it simply for now.
    c:\Propeller_II\P2Load>p2load -v -b 115200 -s LSD_045.obj -h -T
    Trying COM8
    Found propeller version 32 on COM8
    Loading 'LSD_045.obj' at 0x00000e80
    .....
    [ Entering terminal mode. Type ESC or Control-C to exit. ]
    789
    12
    <0D>%<95>
    1A2B3C4D
    4D3C2B1A
    4D3C2B1A
    The fox was here!!
    01000- 0D AA FC 0C 57 AA BC 80 00 AA BC FC 0D D0 FC A0   '....W...........'
    01010- 62 CE FC 1F 37 D0 FC A0 62 CE FC 1F 38 D0 FC A0   'b...7...b...8...'
    01020- 62 CE FC 1F 39 D0 FC A0 62 CE FC 1F 0D D0 FC A0   'b...9...b.......'
    01030- 62 CE FC 1F 59 D0 BC A0 62 CE FC 1F 20 D2 FC A0   'b...Y...b... ...'
    01040- 0D D0 FC A0 60 CE FC 1F 25 D0 FC A0 60 CE FC 1F   '....`...%...`...'
      000- 0D AA FC 0C 57 AA BC 80 00 AA BC FC 0D D0 FC A0   '....W...........'
      004- 62 CE FC 1F 37 D0 FC A0 62 CE FC 1F 38 D0 FC A0   'b...7...b...8...'
      008- 62 CE FC 1F 39 D0 FC A0 62 CE FC 1F 0D D0 FC A0   'b...9...b.......'
      00C- 62 CE FC 1F 59 D0 BC A0 62 CE FC 1F 20 D2 FC A0   'b...Y...b... ...'
      010- 0D D0 FC A0 60 CE FC 1F 25 D0 FC A0 60 CE FC 1F   '....`...%...`...'
    000- 000011 001 1 1111 055 00D
    001- 100000 001 0 1111 055 057
    

    LSD_045.spin
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-13 10:21
    Hi Cluso.

    It is correct what I have wanted.

    Have You merged Check_Serial in this version to ?


    Cluso99 wrote: »
    Sapieha: Not quite sure if this is what you are after...

    I have added the mode #_DUMP+_COG+_CODE
    There are 2 calls in the sample part of the program (lmm_x is the cog address and lmm_y is the mode - they are both sticky with the address incrementing). I have not done hub mode for this yet. I have just coded it simply for now.
    c:\Propeller_II\P2Load>p2load -v -b 115200 -s LSD_045.obj -h -T
    Trying COM8
    Found propeller version 32 on COM8
    Loading 'LSD_045.obj' at 0x00000e80
    .....
    [ Entering terminal mode. Type ESC or Control-C to exit. ]
    789
    12
    <0D>%<95>
    1A2B3C4D
    4D3C2B1A
    4D3C2B1A
    The fox was here!!
    01000- 0D AA FC 0C 57 AA BC 80 00 AA BC FC 0D D0 FC A0   '....W...........'
    01010- 62 CE FC 1F 37 D0 FC A0 62 CE FC 1F 38 D0 FC A0   'b...7...b...8...'
    01020- 62 CE FC 1F 39 D0 FC A0 62 CE FC 1F 0D D0 FC A0   'b...9...b.......'
    01030- 62 CE FC 1F 59 D0 BC A0 62 CE FC 1F 20 D2 FC A0   'b...Y...b... ...'
    01040- 0D D0 FC A0 60 CE FC 1F 25 D0 FC A0 60 CE FC 1F   '....`...%...`...'
      000- 0D AA FC 0C 57 AA BC 80 00 AA BC FC 0D D0 FC A0   '....W...........'
      004- 62 CE FC 1F 37 D0 FC A0 62 CE FC 1F 38 D0 FC A0   'b...7...b...8...'
      008- 62 CE FC 1F 39 D0 FC A0 62 CE FC 1F 0D D0 FC A0   'b...9...b.......'
      00C- 62 CE FC 1F 59 D0 BC A0 62 CE FC 1F 20 D2 FC A0   'b...Y...b... ...'
      010- 0D D0 FC A0 60 CE FC 1F 25 D0 FC A0 60 CE FC 1F   '....`...%...`...'
    000- 000011 001 1 1111 055 00D
    001- 100000 001 0 1111 055 057
    

    LSD_045.spin
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-13 11:39
    Sapieha:
    Here is another update. It now works for hub too.
    I have added two new commands to the Debug/monitor mode (interactive mode)...

    xxx'<cr> will display the cog address (instruction) code, and
    xxxxx"<cr> will display the hub address (instruction) code.
    A <cr> will display the next address.
    Note leading zeros may be omitted in the addresses.
    LSD_046.spin

    No, I have not added the check_serial. I need to think about how to have both options.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 00:00
    Hi Cluso.

    THANKS.

    Now it function that wanted - I can break and see what instructions are doing

    Cluso99 wrote: »
    Sapieha:
    Here is another update. It now works for hub too.
    I have added two new commands to the Debug/monitor mode (interactive mode)...

    xxx'<cr> will display the cog address (instruction) code, and
    xxxxx"<cr> will display the hub address (instruction) code.
    A <cr> will display the next address.
    Note leading zeros may be omitted in the addresses.
    LSD_046.spin

    No, I have not added the check_serial. I need to think about how to have both options.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-14 00:13
    Glad it works for you Sapieha.

    You can also return to your code and continue too. Currently I use <esc> and that terminates p2load's terminal program, so I need to rethink another control char to return to the user cog code.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 04:41
    Hi Cluso.

    I'm are one that never will be happy -- lang_en
    excuse that !

    So I have one question?

    How much work it are to made that?
    
      000- 000011 001 1 1111 057 00D --> 0CFCAE0D --in Ram -> 0DAEFC0C
    

    Ps. Mode for showing Real addressees with instructions Bits --- Give me simpler work to debug my Basic.
    Thanks
    Cluso99 wrote: »
    Glad it works for you Sapieha.

    You can also return to your code and continue too. Currently I use <esc> and that terminates p2load's terminal program, so I need to rethink another control char to return to the user cog code.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-14 06:20
    Easy to do. Do you want both hex values or just reversed if in hub?
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 06:29
    Hi Cluso.

    Thanks

    I wanted both ---> First HEX are for simple showing BIN in correct arrangement
    ---> in RAM are for seek in WinHex else like HEX file editor to find it
    Cluso99 wrote: »
    Easy to do. Do you want both hex values or just reversed if in hub?
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 06:36
    Hi Cluso.

    Next question are more complicated.
    one more command to COG showing

    "<" GoTo Address XXXX

    000<
    Run this addres
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-14 11:04
    goto this address in cog instead of returning to the next address? easy
    what about z and c flags - just ignore?
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 11:45
    Hi Cluso.

    No need for preserve Flags.

    Only GoTo any COG address I specify on DEBUG command line --- So I don't need Edit 1 value in Code -- Recompile and load.

    I simply can place ADD XXXXX,#1 and test many rounds before need for Recompile and reload
    else with RXLine manage moving new value to Variable
    Cluso99 wrote: »
    goto this address in cog instead of returning to the next address? easy
    what about z and c flags - just ignore?
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-14 18:23
    Sapieha: Seems what you really need is for me to add in the single stepper code from my old P1 debugger. But meanwhile, I will add the goto function, maybe later today.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 19:01
    Hi Cluso.

    Not need for single stepper For me.
    I use to that KEY's-1,2,3 on DE2-115

    But to that I need ---- RUN (GoTo) --- XXX address in COG
    Cluso99 wrote: »
    Sapieha: Seems what you really need is for me to add in the single stepper code from my old P1 debugger. But meanwhile, I will add the goto function, maybe later today.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-14 19:22
    Here is v0.47

    Additions:
    xxx!<cr> resumes user code at cog address xxx (i.e. goto). xxx may be omitted for addr=0.
    Dump code now also displays hex and hex reversed in addition to the instruction format. Works for both cog and hub.
    Ctl-Z<cr> now passes control to the Rom Monitor (was <esc> but that conflicts with p2load Terminal mode)
    LSD_047.spin
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 19:51
    Hi Cluso.

    VERY much THANKS.

    Ps. I'm sure I find more things ---- If You will not be crazy on me

    Cluso99 wrote: »
    Here is v0.47

    Additions:
    xxx!<cr> resumes user code at cog address xxx (i.e. goto). xxx may be omitted for addr=0.
    Dump code now also displays hex and hex reversed in addition to the instruction format. Works for both cog and hub.
    Ctl-Z<cr> now passes control to the Rom Monitor (was <esc> but that conflicts with p2load Terminal mode)
    LSD_047.spin
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 20:17
    Hi Cluso.

    Merged with my work on 046.

    Function correctly.
    .....
    [ Entering terminal mode. Type ESC or Control-C to exit. ]
    
    000001D8
    000001E0
    00000008
    0000000A  00A- 100001 110 0 1111 1E0 1D8 - 873FC1D8 D8C13F87
    >
      1D8- 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   '................'
      1DC- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   '................'
      1E0- 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   '................'
      1E4- 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00   '................'
    A,
      00A- D8 C1 3F 87 E0 B1 BF 83 8B 01 7C 1C C1 C0 FF 00   '..?.......|.....'
    A!
    
    000001D8
    000001E0
    00000008
    0000000A  00A- 100001 110 0 1111 1E0 1D8 - 873FC1D8 D8C13F87
    >
      1D8- 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   '................'
      1DC- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   '................'
      1E0- 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   '................'
      1E4- 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00   '................'
    
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 21:23
    Hi Cluso.

    If You don't are crazy on me !!!.

    I have one more question?

    0X0 < LONG else 1 - 8 HEX digits. filled with 0 to made one Long.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-14 21:53
    Sapieha,
    No problems. Glad I can help. Any suggestions/requirements can only make the tool more useful to everyone.
    I am not sure what you are asking on your last request.

    Really looking forward to your Basic.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-14 22:21
    Sapieha:
    If you wish to post your modifications to the _RX routine, I will include them to make it easy for you to comment out or skip my _RX. This should make it easier for your to use my later versions.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 22:40
    Hi Cluso.

    Thanks for that word's
    Cluso99 wrote: »
    Sapieha,
    No problems. Glad I can help. Any suggestions/requirements can only make the tool more useful to everyone.
    I am not sure what you are asking on your last request.

    Really looking forward to your Basic.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-14 22:48
    Hi Cluso.

    What I'm asking for is.

    Input COMMAND to any of COG's
    Long

    0X0 < LONG else 1 - 8 HEX digits. filled with 0 to made one Long.

    0X0 --- Address of COG's mem to write to.
    <
    Command that wait's for imput of HEX value to be placed in COG
    After that wait for input --- If CR
    > move HEX to long specified in 0X0

    Cluso99 wrote: »
    Sapieha,

    I am not sure what you are asking on your last request.

    Really looking forward to your Basic.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-15 02:12
    Sapieha: This will take a little longer. It is on my list to do, both for cog and hub.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-15 05:40
    Was not as difficult as I thought, so here is v0.48

    New DEBUG commands...

    aaa$dddddddd<cr> stores long "dddddddd" into cog address "aaa"

    aaaaa#dddddddd<cr> stores long "dddddddd" into hub address "aaaaa"
Sign In or Register to comment.