Jump to content
sucotronic

Playing music

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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();
     }
   }

Share this post


Link to post
Share on other sites

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-

Share this post


Link to post
Share on other sites

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);
}

Share this post


Link to post
Share on other sites
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.

That's what I thought.

post-2374-135135524901_thumb.jpg

Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined in this statement

main.c

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...