Problem with large constant character strings
Posted: Fri May 23, 2014 2:39 am
I am having a problem with a large const char compiling but not running on the STM32F4 Discovery board. Here is a clip of the code. The line that causes program not to work is down towards the bottom and has a comment to that effect towards the right. Help, ALB.
static WORKING_AREA(waThread2, 128);
static msg_t Thread2(void *arg) {
systime_t time; /* Next deadline.*/
(void)arg;
int P0 = 0;
// const uint8_t menu1[] = //59 * 19 = 1121 bytes
const char menu1[] = //59 * 19 = 1121 bytes
"|-------------------------------------------------------|\r\n"
"| FLEXSTACK TEST MENU |\r\n"
"|-------------------------------------------------------|\r\n"
"| 0 | | Initialize Flexstack |\r\n"
"| 1 | | Run four motor goal list 1 |\r\n"
"| 2 | | Manually enter goal |\r\n"
"| 3 | | Ping |\r\n"
"| 4 | | Read Model Number and FW Version |\r\n"
"| 5 | | Goal 270 degrees, V=57 RPM |\r\n"
"| 6 | | Goal 90 degrees, V=57 RPM |\r\n"
"| 7 | | Read memory values |\r\n"
"| 8 | | Run one motor goal list |\r\n"
"| 9 | | Run two motor goal list |\r\n"
"|-------------------------------------------------------|\r\n"
"| |\r\n"
"|-------------------------------------------------------|\r\n"
"| M | | Menu |\r\n"
"| Q | | Quit |\r\n"
"|-------------------------------------------------------|\r\n"; //59 * 19 = 1121 bytes
const char message1[] = "***** message1 *****\r\n"; // 22 bytes
int str_len1,str_len2;
str_len1 = strlen(message1);
str_len2 = strlen(menu1);
time = chTimeNow();
P0=1;
while(P0) {
chprintf((BaseSequentialStream*)&SDU1, "%s", message1);
chprintf((BaseSequentialStream*)&SDU1, "%s", menu1); // ALB - does not work with this line
chprintf((BaseSequentialStream*)&SDU1, "str_len1 = %d\r\n", str_len1);
chprintf((BaseSequentialStream*)&SDU1, "str_len2 = %d\r\n", str_len2);
// Waiting until the next 250 milliseconds time interval.
chThdSleepUntil(time += MS2ST(100));
}
}
static WORKING_AREA(waThread2, 128);
static msg_t Thread2(void *arg) {
systime_t time; /* Next deadline.*/
(void)arg;
int P0 = 0;
// const uint8_t menu1[] = //59 * 19 = 1121 bytes
const char menu1[] = //59 * 19 = 1121 bytes
"|-------------------------------------------------------|\r\n"
"| FLEXSTACK TEST MENU |\r\n"
"|-------------------------------------------------------|\r\n"
"| 0 | | Initialize Flexstack |\r\n"
"| 1 | | Run four motor goal list 1 |\r\n"
"| 2 | | Manually enter goal |\r\n"
"| 3 | | Ping |\r\n"
"| 4 | | Read Model Number and FW Version |\r\n"
"| 5 | | Goal 270 degrees, V=57 RPM |\r\n"
"| 6 | | Goal 90 degrees, V=57 RPM |\r\n"
"| 7 | | Read memory values |\r\n"
"| 8 | | Run one motor goal list |\r\n"
"| 9 | | Run two motor goal list |\r\n"
"|-------------------------------------------------------|\r\n"
"| |\r\n"
"|-------------------------------------------------------|\r\n"
"| M | | Menu |\r\n"
"| Q | | Quit |\r\n"
"|-------------------------------------------------------|\r\n"; //59 * 19 = 1121 bytes
const char message1[] = "***** message1 *****\r\n"; // 22 bytes
int str_len1,str_len2;
str_len1 = strlen(message1);
str_len2 = strlen(menu1);
time = chTimeNow();
P0=1;
while(P0) {
chprintf((BaseSequentialStream*)&SDU1, "%s", message1);
chprintf((BaseSequentialStream*)&SDU1, "%s", menu1); // ALB - does not work with this line
chprintf((BaseSequentialStream*)&SDU1, "str_len1 = %d\r\n", str_len1);
chprintf((BaseSequentialStream*)&SDU1, "str_len2 = %d\r\n", str_len2);
// Waiting until the next 250 milliseconds time interval.
chThdSleepUntil(time += MS2ST(100));
}
}