BANKing and SX/B (Best practices and pitfalls??)
![RobotWorkshop](https://forums.parallax.com/uploads/userpics/915/nCTRZ4MIBWKDB.jpg)
Hello,
As SX/B programs grow in size and the variables start crossing BANKs what are the best practices for working with them and what are things to watch out for? Will the compiler automatically handle variables that are spread across different BANKs or do they need to be specified in the SX/B program each time a variable has to come from a different BANK.
I've searched through the forum but haven't seen much on this particular topic.
Post Edited (RobotWorkshop) : 2/26/2008 5:45:34 PM GMT
As SX/B programs grow in size and the variables start crossing BANKs what are the best practices for working with them and what are things to watch out for? Will the compiler automatically handle variables that are spread across different BANKs or do they need to be specified in the SX/B program each time a variable has to come from a different BANK.
I've searched through the forum but haven't seen much on this particular topic.
Post Edited (RobotWorkshop) : 2/26/2008 5:45:34 PM GMT
Comments
Arrays are stored in all other (non-default) banks. This is all handled by the compiler.
Only arrays on the SX48 can cross banks, and that is handled automatically.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
At the moment I don't have any single arrays that cross banks. I do however have quite a few variable which are scattered across several banks. That and i've been using the ISR based serial code that JonnyMac had posted to these forums. So far I've resolved quite a few issues (relating to the SX48 timers) but there seems to be one last bug to track down. It appears that some of my variables are getting overwritten and i'm trying to see if perhaps it might be that the RX_BYTE routine changes the BANK to it's own array and then when done explicitly sets it back to BANK 0. I can receive characters ok now (and can send them to 8 LED's for diagnostic) but afterwards get some odd behavior in my program. I'm going to try and walk through it with the debugger but at the moment suspect that the RX_BYTE setting the BANK 0 may be part of the issue if the compiler isn't keeping track that an assembly routine that is being called may have changed the current bank. Does that sound possible or am I way off here? I suppose the debugger will help tell for sure.
Robert
On the SX48 the default bank is $10 NOT $00. That might be the problem.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·