c - sprintf corrupting arrays in IAR microcontroller -


i learning embedded programming, , working on iar-platform using ti microcontroller arm architecture. since not @ familiar technicalities related kind of programming, or c programming in general, ask basic question:

i have following simple code snippet:

int i; for(i = 0; < num_samples; i++) {     sintable[i] = sinf(2*i*dt*pi); }   for(i = 0; < num_samples; i++) {     char out[32];     sprintf(out,"sin: %.7f, %.7f;", i*dt, sintable[i]);     putstring(out);     delay(delay_100us); } 

where sintable[] global variable of size num_samples, putstring(*char) function writes rs232-port, , delay(float) simple delay-function.

my problem once sprintf(...) called, corrupts sintable, giving peculiar results when plotting table on receiver end of com-signal.

i don't expect run out of memory, mc has 64kb sram.

does have thoughts?

ensure stack pointer on 64-bit boundary when main reached.

the symptom seeing typical of stack aligned on odd 32-bit boundary. seems work until double used variadac argument. breaks when code expects such arguments on 8-byte boundaries.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -