Wierd wierd function behavior... - MCS08GT32A

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Wierd wierd function behavior... - MCS08GT32A

1,357 Views
Rubberduck
Contributor I

I really hope someone can tell me whats is going wrong, im fairly new to c/codewarrior and to the HCS08GT32A microcontroller. The following doesn't make any sense me :smileysad:.

 

my main looks like this:

void main(void)

  char *test_str = "111222333";
  
  system_setup();
 
  for(;:smileywink:
  {
     display_string_still(test_str);
  }
}

void display_string_still(incomming_str)

  unsigned char disp_buffer[BUFFER_LENGTH][BUFFER_HEIGHT]; //BUFFER_LENGTH = 4  BUFFER_HEIGHT = 10
  unsigned char i;
  unsigned char j;
  
  display_string_rolling_left(incomming_str);
  

  for(i = 0; i < BUFFER_LENGTH; i++)
  {
    for(j = 0;j < BUFFER_HEIGHT; j++)
    {
      disp_buffer[i][j] = 0b00000000;
    }
  }

}

The above code doesn't work... But if I out comment the two for-loops it will run perfectly(display_string_rolling_left(incomming_str) is then working and making the text roll on my LEDS). But why?... First of all the for-loops occurs after the display_string_rolling_left(incomming_str) function call. To my knowledge these things should be executed sequential? And since the disp_buffer is a local variable, it shouldn't influence anything out of this void display_string_still() scope?.. Or am I missing something(which problerly is the case since im new in this microcontroller world :smileywink:) ?

 

 

Thanks in advance!

Rubberduck

 

Added p/n to subject.



Message Edited by NLFSJ on 2008-12-17 07:47 AM
Labels (1)
0 Kudos
2 Replies

241 Views
Lundin
Senior Contributor IV
First of all, 0b00000000 is not valid C and will not compile on any standard C compiler.

Apart from that, I suspect that the problem is related to a stack overflow. You are allocating 40 bytes on the stack at each function call.

What does "going wrong / doesn't work" mean, more specifically?
0 Kudos

241 Views
Rubberduck
Contributor I
You were right, it was the stacksize that was too small, so it runs again now :smileyhappy: Thanks alot for your answer!:smileyvery-happy:
 
What i meant with the going wrong thing, was that the display_string_rolling_left(incomming_str);
 was the place where the stack overflow was occuring, so i was just confused, since a change in function A made function B go mad, but I learned something, and thanks again :smileyhappy:
0 Kudos