stryd_one Posted May 29, 2006 Author Report Share Posted May 29, 2006 In my defense I wrote this with minutes on the clock since my girlfriend was yelling at me to get off the damn computer since we were going out for the night :)LOL ;DBeen there before! Quote Link to comment Share on other sites More sharing options...
th0mas Posted May 29, 2006 Report Share Posted May 29, 2006 stryd_one:My most preferenced solution would be to use nested structs, since it naturally represents our dataset. linked lists are unnecessary since the number of elements is predefined, and I think you will want random accesses, since if a user turns on track 4, step 8, you don't want to iterate over data members to find the entry.. probably create bad timing issues.So you'd want something like:typedef struct _step { unsigned char Note; unsigned char Velocity; unsigned char Length;} step_t;typedef struct _track { step_t Step[16]; unsigned char Divider; // there is a reason we put these three lonely members behind the Steps unsigned char Direction; unsigned char Mute;} track_t;typedef struct _pattern { track_t Track[32];} pattern_t;// to allocate a pattern on the stack:pattern_t pattern;// to access a specific value:pattern.Track[2].Step[15].Velocity = 0x7F;total size of pattern = 32 * ((16*3) +3) = 1632 bytes. I don't know if SDCC can handle allocating this much memory when it's in a nested structure usage, but I'm guessing the 256 byte issue still applies, which means, it won't. I think in order for you to access this much data, you will have to:- use a custom linker script in order to allocate a named block of memory >256 bytes.- you will most likely then have to manually calculate the offset into the memory region.To someone who knows: does SDCC support pointers? Not dynamic memory, just the allocation of pointers to say, a struct. If so then stryd could just use the linker script entry to allocate the memory, and then allocate on the stack a pointer to a pattern, and then map the pointer to a pattern onto the memory block. Quote Link to comment Share on other sites More sharing options...
audiocommander Posted May 30, 2006 Report Share Posted May 30, 2006 Thanks mate, I'll take that into account.(...)I'm still stuck on the right way to section this memory off if not using arrays though :\But don't give too much weight on my unexperienced opinion here, I will post some more questions about this in the Bankstick Storage Thread...Again, guys I have to thank you for the advice. I understand if this is taking too much of your time and I totally understand if you have to tell me to go away and do some more reading As I am actually thinking about the same issue (but different data, of course), I feel quite lucky having the possibility to chat with some mates. My girlfriend is not really enjoying that kind of talks ;DCheers, Michael Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 30, 2006 Author Report Share Posted May 30, 2006 Hey, you might call yourself inexperienced, but look at me! ;)As I am actually thinking about the same issue (but different data, of course), I feel quite lucky having the possibility to chat with some mates. My girlfriend is not really enjoying that kind of talks ;DLMAO ;D Quote Link to comment Share on other sites More sharing options...
stryd_one Posted May 30, 2006 Author Report Share Posted May 30, 2006 My most preferenced solution would be to use nested structsI was starting to think that might be the way to go too, but I wasn't sure if you could nest arrays of structs like that. It sure looks like what I wanted though!total size of pattern = 32 * ((16*3) +3) = 1632 bytes. I don't know if SDCC can handle allocating this much memory when it's in a nested structure usage, but I'm guessing the 256 byte issue still applies, which means, it won't. I think in order for you to access this much data, you will have to:- use a custom linker script in order to allocate a named block of memory >256 bytes.- you will most likely then have to manually calculate the offset into the memory region.To someone who knows: does SDCC support pointers? Not dynamic memory, just the allocation of pointers to say, a struct. If so then stryd could just use the linker script entry to allocate the memory, and then allocate on the stack a pointer to a pattern, and then map the pointer to a pattern onto the memory block.The scary thing is that that's a cutdown version and It'll probably be bigger than that... I've had a look at the other variables that I'll need to use and I think that I'll have to cut it down to 24 tracks in order to make it fit in the available RAM even on the 4620 :( That is, until I get the SRAM interface working, but that's a little while off (read: way above my skill level) at the moment! I was thinking about including some tracks of shorter lengths (3,4,5,6,8 steps) too, but now I'm getting sidetracked... (Hey, while I'm sidetracked, the vX is getting partial polyphony! woo!)When I get a break (yeh, right) I want to test the arrays with SDCC, to find out if the limitation is to 8-bit array sizes (as in, no arrays over 256k) or 8-bit addressing to the arrays. I reeeeaaaallly hope it's the latter! Quote Link to comment Share on other sites More sharing options...
stryd_one Posted June 25, 2006 Author Report Share Posted June 25, 2006 The results are in: the arrays can be addressed with >8bits (so array[1024] is still OK) but any variable including the array's total size, is limited to 256bits. This limitation can be overcome by using a customized linker script. I will document this on the wiki shortly. Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 27, 2006 Report Share Posted June 27, 2006 Would my assumption be correct in thinking that you are looking to change controller values of buttons and knobs on the fly without having to use a bankstick? Quote Link to comment Share on other sites More sharing options...
stryd_one Posted June 28, 2006 Author Report Share Posted June 28, 2006 You're close :)I'm trying to make all the sequencer parameters available. Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 28, 2006 Report Share Posted June 28, 2006 A while back you gave me assistance (ACommander also) on changing controller values for my Native Instruments B4 controller. I don't know if that is what you are hitting at, but look again at the post- do a search on 'boolean', it will be the first link.Weel, mission accomplished. I use a 3 pole switch to toggle between a variety of functions for each pot and switcheg- position 1- knob 1 is upper manual 16' pipe on channel 1position 2- knob 1 is lower manual 16' pipe on cahannel 2 etc.Would the code for this help you. I only completed it two days ago, and am too busy playing with it to post the WIKI. So if you want I'll post the code here if you think it would help!MP Quote Link to comment Share on other sites More sharing options...
stryd_one Posted June 29, 2006 Author Report Share Posted June 29, 2006 Glad to hear it worked :)I don't think this is the right kind of thing for me, because the seq handles things a bit differently to the controller, but if you PM it to me, I'll wiki it up for the community :) (with credit to you of course!) Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 29, 2006 Report Share Posted June 29, 2006 With credit to Audiocommander for his assistance!! Quote Link to comment Share on other sites More sharing options...
stryd_one Posted June 30, 2006 Author Report Share Posted June 30, 2006 You can find documentation on how to alter the linker script for larger variables (including big multidimensional or nested arrays and structs), as a part of the doco for using the 4620:http://www.midibox.org/dokuwiki/doku.php?id=using_pic18f4620Hope this helps.edit: new link Quote Link to comment Share on other sites More sharing options...
henrygr Posted June 30, 2006 Report Share Posted June 30, 2006 Now I get you......Have bookmarked that bit of code for future use.Cheers. :) Quote Link to comment Share on other sites More sharing options...
audiocommander Posted June 30, 2006 Report Share Posted June 30, 2006 hey, that's a nice work, stryd_one :)...but maybe we should put that on an extra page to avoid confusion for beginners. I think this is quite a special topic and not really relevant for the oversight intro-page to app-coding with MIOS?what do you think?Cheers, Michael Quote Link to comment Share on other sites More sharing options...
stryd_one Posted July 1, 2006 Author Report Share Posted July 1, 2006 Agreed. I'll split it into a page of it's own today :)done: http://www.midibox.org/dokuwiki/doku.php?id=using_pic18f4620 Quote Link to comment Share on other sites More sharing options...
mess Posted July 1, 2006 Report Share Posted July 1, 2006 I agree with AC, nice work on the wiki :D Quote Link to comment Share on other sites More sharing options...
stryd_one Posted July 1, 2006 Author Report Share Posted July 1, 2006 I'm still fearing TK posting and going "That's all wrong" hehehehe Quote Link to comment Share on other sites More sharing options...
jackchaos Posted October 30, 2006 Report Share Posted October 30, 2006 th0masYou posted the code below and I'm trying to follow the meaning of this thread. This looks interesting!Can the SDCC compiler handle this for the PIC? Is this a better way to handle things than a simple multi-dimensional array?RegardsSo you'd want something like:typedef struct _step { unsigned char Note; unsigned char Velocity; unsigned char Length;} step_t;typedef struct _track { step_t Step[16]; unsigned char Divider; // there is a reason we put these three lonely members behind the Steps unsigned char Direction; unsigned char Mute;} track_t;typedef struct _pattern { track_t Track[32];} pattern_t;// to allocate a pattern on the stack:pattern_t pattern;// to access a specific value:pattern.Track[2].Step[15].Velocity = 0x7F; Quote Link to comment Share on other sites More sharing options...
stryd_one Posted October 31, 2006 Author Report Share Posted October 31, 2006 It does work :)It's not really a better way - it's the only way ;) heheh ....Multidimensional arrays just won't work at all unfortunately :( Quote Link to comment Share on other sites More sharing options...
jackchaos Posted October 31, 2006 Report Share Posted October 31, 2006 "....Multidimensional arrays just won't work at all unfortunately"You mean, they don't work for arrays larger than 256? Or at all? But for smaller ones, they are fine.... especially for const unsigned char myarray[32][4] or some such...I see. I re-read this entire thread. Stryd needs data storage for real-time, in memory stuff. I worried that my flash stored constant multi-dimension arrays are a problem. I see they are not. Quote Link to comment Share on other sites More sharing options...
stryd_one Posted October 31, 2006 Author Report Share Posted October 31, 2006 :) Quote Link to comment Share on other sites More sharing options...
stryd_one Posted February 11, 2008 Author Report Share Posted February 11, 2008 Due to a restriction to SDCC, bitfields are limited to 8 bits! :-\For the record:Good news, I have just tested a 15-bit bitfield (15, not 16, to test correct alignment of odd sizes across bytes), and all accesses are correct :)This was with a post 2.7.0 SDCC release. 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.