In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote: Attached is my current dynamic vp library. This provides background routines (so these run inside the interrupt) that are easily added to sxb 2.0 applications. The demo file shows how libraries are imported. There are 3 libraries. The SXB_ConMac library contains general constants and macros. My demo program uses INTERRUPT NOCODE so no __PARAMx variables are saved during interrupt. The VP interrupt code does not use these but additional isr code may. There are macros SaveALLparams and SaveTASKparams (TASKS only use __PARAM1 and __PARAM2) so when running TASKS as well, such a macro must be used. These macro calls are included in the isr routine as comments. The PortPins library contains constants for ports and pins and subroutines and functions to manipulate ports and pins via variables. The DynamicVP library contains the VP interrupt code (encoded in 3 macros) plus subroutines and functions in SXB that you use to pass values to and from the VP drivers. VP's are defined by 15 bytes of CDATA. There can be up to 6 VP slots. Each slot occupies a ram bank of 16 bytes and each VP slot adds 31 cycles to the interrupt. With 6 slots the isr always takes 196 cycles. You can run the demo through SxSim v2.08.06 (this is the most recent SxSim version) and observe the isr cycle count. Important to note: up to now this has been coded using SxSim only. I have not yet programmed any sx chip with the demo. That is the next stage. But I wanted to share it now so this can be used as a showcase how to implement libraries. Also, if people want special VP features I'd like to hear them while doing real silicon testing so I might add these at this point as that seems more easy than incorperating new features afterwards. For those that want to experiment: there are conditional switches near the top of the demo program that you can use to enable/disable certain VP types. The idea is that an application only enables the VP types it wants to use. If you do that you will need to comment out some code in the demo program that uses the VP type. No changes should be made to the libraries. Everything is controlled from the demo program. Just unzip the attachement in some folder and load the demo program in the IDE. If you have any questions about the code, just ask. But note that I have no hardware setup yet. regards peter ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=328202 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)