Duggle Posted September 1, 2010 Report Share Posted September 1, 2010 The idea is inspired by the desire to drive DOUT attached LED's with individual variable brightness. Rather than have a single dimension array volatile u8 mios32_srio_dout[MIOS32_SRIO_NUM_SR]; The idea is to have 2D array with a number of buffer pages: #define DOUT_NUM_BUFPAGES 2 volatile u8 mios32_srio_dout[DOUT_NUM_BUFPAGES][[MIOS32_SRIO_NUM_SR]; At a lower level MIOS would alternate pages by presumably setting a pointer prior to each DMA transfer. In the above example any attached LED could be run at 100%, 50% (or 0%) brightness. When setting the brightness level for a particular LED, the same bit is set and/or cleared in different pages. Taking the concept further #define DOUT_NUM_BUFPAGES 10 would produce 10 level, 100Hz, brightness control. Actually its does not have to be Pulse Width Modulation exactly. It is more like Pulse Density Modulation (if such a term exists). This is because the on and off bits can be randomly distributed in the pages, for any given LED. When set, the background processing is achieved with almost zero extra overhead. Just updating the page pointer each SRIO cycle? Quote Link to comment Share on other sites More sharing options...
TK. Posted September 1, 2010 Report Share Posted September 1, 2010 A nice idea - I haven't considered such possibilities yet since MIOS8 was always restricted on RAM limitations. Note that the same concept can be used to drive a LED matrix - e.g. set DOUT_NUM_BUFPAGES to 8 and output (1 << counter) to an additional DOUT register. If you are working on an extension on MIOS32, you could consider this usecase as well. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Duggle Posted September 2, 2010 Author Report Share Posted September 2, 2010 (edited) Note that the same concept can be used to drive a LED matrix - e.g. set DOUT_NUM_BUFPAGES to 8 and output (1 << counter) to an additional DOUT register. If you are working on an extension on MIOS32, you could consider this usecase as well. Sure, but I'm not quite sure how the additional DOUT register is wired to the matrix, and why 8 pages? Edit: Having thought a some more about this, if there is a page each for the number of matrix columns,then row/column matrix's can be driven this way. Edited September 4, 2010 by Duggle Quote Link to comment Share on other sites More sharing options...
Duggle Posted September 6, 2010 Author Report Share Posted September 6, 2010 Ok, looks simple enough. As an extension to MIOS32 define volatile u8 mios32_srio_dout_bufpages[DOUT_NUM_BUFPAGES][[MIOS32_SRIO_NUM_SR]; //paged buffer dout arrayA family of helper functions to set the page data for RGB, TriLED, single variable brightness LED, row/col matrix wired LED, etc.define MIOS32_SRIO_ScanStart_DoutPaged() which has a rotating index when providing a dout array pointer to MIOS32_SPI_TransferBlock(..)Put a #ifdef switch in void vApplicationTickHook(void) so that MIOS32_SRIO_ScanStart_DoutPaged() is called instead of MIOS32_SRIO_ScanStart() Question: Is there a way of achieving (4.) without modifying MIOS32 source code? If I'm correct then the rest can be achieved as a pure add on module i.e not modifying MIOS32 source. I'm very happy to commit to the repo, but I dont want to "bloat" anything! Quote Link to comment Share on other sites More sharing options...
Duggle Posted September 29, 2010 Author Report Share Posted September 29, 2010 (edited) Well I can report the method certainly works well. To proceed as simply as possible I've added s32 MIOS32_DOUT_SRSet_Paged(u32 pg, u32 sr, u8 value) and s32 MIOS32_DOUT_SRGet_Paged(u32 pg, u32 sr) to mios32_dout.c for get/setting the data. Plus changed s32 MIOS32_SRIO_ScanStart(void *_notify_hook) to roll through the pages with each execution. I use conditional compilation to allow for compiling normal unpaged dout apps. I think this is the most transparent and simplest way for now. I'll continue to develop the application support routines for this and report back later! Edited September 29, 2010 by Duggle Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.