PDA

View Full Version : Is it a bug or am I just wrong?



cncmachineguy
- 21st December 2010, 01:17
Here is the issue. I am under the impression that PBP will tend to BANKS for me. So naturally I assume this:


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.




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?

Darrel Taylor
- 21st December 2010, 02:20
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.

Darrel Taylor
- 21st December 2010, 02:34
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 ... :o

cncmachineguy
- 21st December 2010, 03:47
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.

Acetronics2
- 21st December 2010, 09:58
Here is the issue. I am under the impression that PBP will tend to BANKS for me. So naturally I assume this:


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.




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**** !!! :D

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


Alain

cncmachineguy
- 21st December 2010, 14:09
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! :))