PBP array in ASM statements


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: PBP array in ASM statements

    ...nevermind... keep thinking...
    Last edited by mister_e; - 28th May 2011 at 21:47.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: PBP array in ASM statements

    The same is happening with @ CLRF _Counter +1.
    And ISR stops, sometimes begins to run, sometimes I have to reset my pic

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: PBP array in ASM statements

    I'm tad rusty, for ease... I would bet your should assign your array to BANK0 instead...

    post your PIC model and code, we'll try to help
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: PBP array in ASM statements

    Here it is ISR
    Code:
    if PIR2.1=1 then
       T3CON=%00000110
       Wp= Wp & uwp
       Xn.0=IN1
       Xn.1=IN2
    
       
       IF (Xn.0<Xs.0 AND Trf=0) OR  (Xn.0<Xs.0 AND Xn.1=1 AND Trf=1) THEN
    @     INCF _Counter,F 'this work
          IF Counter[0] = Mtp2[0] OR (Counter=256 AND Mtp2[0]=0)THEN
    @      CLRF _Counter ' and this
              CNT[0]=CNT[0] + Add[0]
          ENDIF
       ENDIF
       
       IF (Xn.1<Xs.1 AND Trf=0) OR (Xn.0<Xs.0 AND Trf=1 AND Xn.1=0) THEN
    @     INCF _Counter+1,F 'Counter[1] = Counter[1] + 1  'won't work
          IF Counter[1] = Mtp2[1] OR (Counter[1]=256 AND Mtp2[1]=0)THEN
    @      CLRF _Counter+1'Counter[1]=0 'won't work
              CNT[1]=CNT[1]+Add[1]
          ENDIF
       ENDIF
       Xs=Xn
    
    @  CLRF PIR2
    endif
    Pic is 18LF14K50
    EDIT:
    bank0 or bankA is same...
    I tried RTC,it works fine with both.
    Last edited by pedja089; - 28th May 2011 at 22:14.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: PBP array in ASM statements

    weird... a simple loop works here,

    Code:
    start:
        asm
            incf _MyArray,F
            incf _MyArray+1,F
        endasm    
        myvar=myarray[0]
        myvar2=myarray[1]
        goto start
    but as you're using a blend mix of ASM and PBP in an ISR, you must make sure you're always on the good BANK case not, hell yeah it may goes to lalaland... what you could try is to set all variable that goes in the ISR to BANKA.

    And yes I know I miss something

    EDIT: The more I think, the more it looks like a bank switching issue,
    Code:
        MyArray VAR BYTE[8] BANK1
        
        MyVar var byte BANK0
        MyVar2 var byte BANK0
        clear
    
    start:
        asm
            CHK?RP _MyArray
            incf _MyArray,F
            incf _MyArray+1,F
        endasm    
        pause 500
        myvar=myarray[0]
        myvar2=myarray[1]
        goto start
    The above work... commentout the CHK?RP line.. and nope... it doesn't.

    And NOPE, BANK0 !=BANKA
    Code:
    BANKA   $0000, $005F
    BANK0   $0060, $00FF
    Finger crossed before the real ASM/Compiler gurus came here and slap me a good one
    Last edited by mister_e; - 28th May 2011 at 22:58.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: PBP array in ASM statements

    As you can see, my isr have both and asm and pbp... All variables is in bankA.
    Somewhere i read that bank for 18F doesn't matter...
    How to setup correctly banks?
    But if I use i = i +1 instead INCF everything works. INCF and CLRF work if I make a array to separate variables...

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: PBP array in ASM statements

    Since we don't have the full code, or .LST file, I'll leave the more in deep & technical explanation of Access Ram, BSR and plah plah plah of section 3.3.3 to better guys (I hope I'm right though ).

    Again, the compiler keep track of everything for you, hence why the PBP lines will always works.

    add
    @ CHK?RP _Counter
    just before your INCF, DECF and or CLRF to see what happen
    Last edited by mister_e; - 28th May 2011 at 23:31.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts