bluehash 1,581 Posted April 27, 2011 Share Posted April 27, 2011 Sorry my mistake. This will not work. I totally forgot that the MSP430g2231 has 128bytes of RAM, which is 80h. No wonder it cannot allocate stack. Increasing the stack will not help. Do you have a chip with bigger memory. One thing you can do is remove any unused variables or optimize. If you dont know how to do that, I'll walk you through. timotet 1 Quote Link to post Share on other sites
timotet 44 Posted April 27, 2011 Share Posted April 27, 2011 Bluehash your the man One thing you can do is remove any unused variables or optimize. If you dont know how to do that, I'll walk you through. Thanks for taking the time to help with this. the MSP430g2231 has 128bytes of RAM, which is 80h. Well now that makes sense! Do you have a chip with bigger memory. yes I do. I think the first post uses the g2211 I was trying to use a G2201, same specs as G2211 as far as memory goes so how to optimize? Quote Link to post Share on other sites
bluehash 1,581 Posted April 28, 2011 Share Posted April 28, 2011 There are optimization options in the Liker Options. Right click Prokect and select Build Properties. I'll try your program and see if I can reduce it is size. Also change eint() ---to---> _enable_interrupts() dint() ---to---> _disable_interrupts() nop() ---to---> __no_operation() Also change int notes[] = { } to const int notes[] = { } const makes the array read only which puts it into Flash and not RAM. That give more space for the stack. Modified file attached. Not Tested. Compiles and links fine. music.c timotet 1 Quote Link to post Share on other sites
timotet 44 Posted April 28, 2011 Share Posted April 28, 2011 bluehash Thanks for your time with this. I changed the int notes to const int notes and that was it. It also works with or without the _disable_interrupts() command. It has to have the __no_operation() command. return does not work . It works with or without #include . Isnt this for interrupts in mspgcc? I was thinking about this yesterday after we had been working on it and had the thought that changing int notes to const int notes might do the trick. All though I did not know what exactly that did. So its nice to know for the future. thanks again Quote Link to post Share on other sites
bluehash 1,581 Posted April 28, 2011 Share Posted April 28, 2011 Good to know. Have fun and thanks for keeping us updated. Quote Link to post Share on other sites
jsolarski 94 Posted May 4, 2011 Share Posted May 4, 2011 #include is for interrupts in mspgcc bluehash 1 Quote Link to post Share on other sites
nuetron 64 Posted November 23, 2011 Share Posted November 23, 2011 Could someone tell me exactly what this does? /** Delay function. **/ void delay(unsigned int ms) { volatile unsigned int i,ms2; i = time; ms2 = ms*2; while ((time-i) < ms2) { _NOP(); } } Quote Link to post Share on other sites
Fe2o3Fish 33 Posted November 23, 2011 Share Posted November 23, 2011 Well, it's a time delay function. :-) First, I'd say that 'time' is the system's idea of time, albeit only an int. Second, I'd say that the time is kept in 1/2-millisecond increments thusly the delay value (in msecs) is doubled. That's a little different way of doing a delay (continually comparing the time difference) but it seems like it would work. Am I missing something?? -Rusty- nuetron 1 Quote Link to post Share on other sites
oPossum 1,083 Posted November 23, 2011 Share Posted November 23, 2011 The time variable in incremented in the watchdog timer interrupt handler interrupt(WDT_VECTOR) watchdog_timer (void) //__interrupt void watchdog_timer { time++; } I think the code could be simplified... interrupt(WDT_VECTOR) watchdog_timer (void) //__interrupt void watchdog_timer { --time; } void delay(unsigned ms) { time = ms * 2; while(time); } Quote Link to post Share on other sites
nuetron 64 Posted November 23, 2011 Share Posted November 23, 2011 I'd say that the time is kept in 1/2-millisecond increments thuslythe delay value (in msecs) is doubled. That's a little different way of doing a delay (continually comparing the time difference) but it seems like it would work. That's what I thought. Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement main.c Quote Link to post Share on other sites
bluehash 1,581 Posted November 23, 2011 Share Posted November 23, 2011 Breakup the volatile declaration: volatile unsigned int i; volatile unsigned int ms2; Quote Link to post Share on other sites
Fe2o3Fish 33 Posted November 23, 2011 Share Posted November 23, 2011 And since 'i' and 'ms2' don't change, neither should be declared volatile. Quote Link to post Share on other sites
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.