Is it a bug or am I just wrong?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Is it a bug or am I just wrong?

    Here is the issue. I am under the impression that PBP will tend to BANKS for me. So naturally I assume this:
    Code:
    PIR1.1 = 0
    will be included and PBP will select bank 0 before executing this command. Here is my test code to prove to myself this IS NOT the case.

    Code:
    MAIN: 
    
       PIR1.1 = 0  
    @MOVLW 3        'must use ASM so PBP doesn't set bank to "0" and get it right 
    @MOVWF BSR    'by default.
       PIR1.1 = 1       ' This does not happen! PIR1.1 still = 0
    @CLRF BSR
       PIR1.1 = 1       ' This one happens now that I have set the BSR to correct bank
       GOTO MAIN
    Now if this is a bug, so be it. we can all work around and move on with our day. If this is not a bug, is there a way to find out what things DON'T set the correct bank?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    It is NOT a bug!
    Most likely it is MPSIM, which I never got reasonable results from.
    Which is why I was so happy to find Proteus, which has no problem with your program.

    It would make no sense at all for that to happen.

    Your program only has 5 byte variables, so CNT is already in BANK0.
    PORTA is in BANK0.
    PORTC is in BANK0.
    PIR1 is in BANK0.
    The bank never changes while in the interrupt handler.

    I'm affraid you are chasing problems that do not exist, except within MPSIM.
    DT

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    OK, wait a minute ... sorry.
    I forgot, it's not using DT_INTS anymore.

    While the 16F1's do save context automatically, they do not reset BSR.
    Whatever bank it's in when the interrupt happens is the bank you are in when getting to the ISR.

    BSR = 0
    Should be the first statement in an ISR that is not using DT_INTS.

    Blushing ...
    DT

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    To be clear. MPSIM is how I solved the problem. My card not working is how I found there was a problem.

    OK, I think I get it now. PBP expects BSR to be cleared. So anything that happens in BANK 0 doesn't need to have bank 0 selected. That makes perfect sense. It also clears up why cnt doesn't inc even though the program just loops through the int over and over when it hangs. Cuz its in BANK 0!!

    So the only thing I don't get now is why it works for you in Protus. Hmmm, I have been thinking about getting this next year (they say support for 16F1xxx's should happen then), but things like this just scare me.

    Thanks for pointing out BSR=0 should be the first thing, I guess every so often I am not adding 1 to count right now. And THANK YOU so much for finally clearing this up for me. It has been a struggle for a couple weeks now.

    For the record, I have not been chasing a problem in MPSIM, the problem is in real life on a real life card. When the LED quit flashing, I knew there was a problem. It was real simple to keep reming the line, programming the actual chip, watch it fail. un-rem the line, program the actual chip, watch it run. After doing this over and over, I decided there was a problem I didn't understand and posted.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cncmachineguy View Post
    Here is the issue. I am under the impression that PBP will tend to BANKS for me. So naturally I assume this:
    Code:
    PIR1.1 = 0
    will be included and PBP will select bank 0 before executing this command. Here is my test code to prove to myself this IS NOT the case.

    Code:
     
    MAIN: 
     
       PIR1.1 = 0  
    @MOVLW 3        'must use ASM so PBP doesn't set bank to "0" and get it right 
    @MOVWF BSR    'by default.
       PIR1.1 = 1       ' This does not happen! PIR1.1 still = 0
    @CLRF BSR
       PIR1.1 = 1       ' This one happens now that I have set the BSR to correct bank
       GOTO MAIN
    Now if this is a bug, so be it. we can all work around and move on with our day. If this is not a bug, is there a way to find out what things DON'T set the correct bank?
    Hi Bert

    you place bank pointer to Bank3 ...
    PIR1 is located in Bank 0 ...

    no surprise it doesn't modify PIR1

    BUT you modified EEADRL ...

    IF any sim has shown a mod to PIR1 ... pass by this bull**** !!!

    a good practise is to use @ BANKSEL PIR1 before using the register ... which will automatically select the good Bank ...


    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Hi Alain, the above program is not a program I am trying to use, it is one I made up to test if PBP set the BSR for the PIR line. (I was having a problem in a different program relateing to PIR bank selecting)
    Now that Darrel has cleared up for me that PBP always resets BSR to 0 after every non BANK0 operation, I now understand why the above doesn't work. Prior to this clarity, I was thinking PBP ALWAYS selected the bank for every operation. Just more info for my brain to keep in mind when mixing ASM in or when using interupts. I HATE learning curves! )
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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