If I am just being thick headed let me know...Code:BSR = 0 'IN BANK 0
LATF = LATF ^ 32 'NOW IN BANK 7
CNT =CNT+1 'NOW WHAT???
Printable View
If I am just being thick headed let me know...Code:BSR = 0 'IN BANK 0
LATF = LATF ^ 32 'NOW IN BANK 7
CNT =CNT+1 'NOW WHAT???
when PBP sees the LATF line, it switches to bank 7. when its done it automaticlly switches back to BANK 0. This way PBP can know it is always in BANK 0. So when it sees PIR1.1=0, this is a BANK 0 thing, it assumes it is in BANK 0 so it doesn't reset BSR. Now sometimes when my ISR is called, I was already in BANK 5. If the LATF line is in, PBP switches to 7, then back to 0 when done with LATF. When I rem LATF and enter the ISR in BANK 5, PBP doesn't know. So then everything that is supposed to happen in BANK 0 can't.
Adding BSR=0 as the first line in my ISR will ensure PBP won't be confused. Because the chip I am using does auto context save and restore, I don't need to worry about destroying the BSR in my ISR.
I get it now..
LAT was/is doing the same thing as BSR , as far as the BANKs are concerned.
Thanks!!!!
now it is time for a nap..
Whew, thanks again Darrel. I was really having second thoughts for a min. Now my brain is all re-aligned for whatever tomorrow brings :)
For the sake of clarity, LAT was not really doing the same thing as BSR. What it was doing was causing PBP to change banks to BANK7, therefore PBP also changed banks back to BANK0 when the LAT was done. With it remed, PBP assumed it was still in BANK0. SO when I entered the ISR with a different bank set, PBP didn't know. I gather from Darrels help in my "bug" thread, He tends to the BSR=0 in his DT_INT routine to avoid just such issues.
BTW, the only reason I can change BSR inside my ISR is because 16F1xxx automatically saves BSR upon entering an interupt. So BSR will change back when I return. Otherwise I would have needed to save the BSR to a temp, then restore it before leaving ISR.
Next up on the list of games is multiple interupts and checking who fired. :)
This is great fun!!!
Been a while since I posted anything here. I am still working on this but things slowed through the holidays then I had some mechanical issues to resolve with the machine. But I am back on this now. Anyhow, here is my problem:
I have limit switches on each axis of travel. 1 switch also doubles as a home switch for each axis. Because I have too much I/O to report everything to EMC, I am using my card to watch the switches. This way I can report the "home" switches and throw an E-stop if any other limits are hit.
Now for the question: when the machine homes, it is set up to do 1 axis at a time, leaving the axis on the home switch. I need to be able to ignore the switch until homing is complete (i have that working) but also need to ignore them until the first time the axis moves off the switch. Does this make sense? I am sure this will need some flags, but I am at a loss as to how to do the checking without having a zillion IF's and so forth.
Any suggestions/questions?
Finally got past my logic issues, Just thought I would post a pic of the card with stepper drives attached.
Attachment 5167
Thanks to all who have helped me get this far. This is a fully functional "phase 1" card. Now the fun really begins :)
BTW, for any who are intrested, pics of the machine will be up soon over at Foam Casualty
Nice!!!
Looking forward to seeing vids of it running.
Thank you,
They are coming Dave :)