[MSPM0L1306 SSM] UART 테스트 - printf 사용하기 예제를 참고로 해서 UART 테스트를 진행 하려고 하는데 컴파일 에러가 발생한다.
UART 설정을 하고 printf를 사용하면 에러가 발생한다.
SRAM이 너무 작다. 메모리 옵션을 조절하면 사용할 수 있겠지만… 다른거 몇개 넣고 나면 또 메모리 부족이 나온다.
아~ 저렴하게 하려고 너무 아끼는것 아닌가? 이렇게 까지 해서 써야 하나 싶다.
"C:/ti/ccs1280/ccs/tools/compiler/ti-cgt-armllvm_3.2.2.LTS/bin/tiarmclang.exe" @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O2 -gdwarf-3 -Wl,-m"gpio_toggle_output_LP_MSPM0C1104_nortos_ticlang.map" -Wl,-i"C:/ti/mspm0_sdk_2_02_00_05/source" -Wl,-i"D:/WORK/MSPM0L/mspm0c1104/gpio_toggle_output_LP_MSPM0C1104_nortos_ticlang" -Wl,-i"D:/WORK/MSPM0L/mspm0c1104/gpio_toggle_output_LP_MSPM0C1104_nortos_ticlang/Debug/syscfg" -Wl,-i"C:/ti/ccs1280/ccs/tools/compiler/ti-cgt-armllvm_3.2.2.LTS/lib" -Wl,--diag_wrap=off -Wl,--display_error_number -Wl,--warn_sections -Wl,--xml_link_info="gpio_toggle_output_LP_MSPM0C1104_nortos_ticlang_linkInfo.xml" -Wl,--rom_model -o "gpio_toggle_output_LP_MSPM0C1104_nortos_ticlang.out" "./gpio_toggle_output.o" "./ti_msp_dl_config.o" "./startup_mspm0c110x_ticlang.o" -Wl,-l"./device_linker.cmd" -Wl,-ldevice.cmd.genlibs -Wl,-llibc.a
makefile:137: recipe for target 'gpio_toggle_output_LP_MSPM0C1104_nortos_ticlang.out' failed
warning #10210-D: creating ".sysmem" section with default size of 0x800; use the -heap option to change the default size
"./device_linker.cmd", line 62: error #10099-D: program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. run placement with alignment fails for section ".sysmem" size 0x800. Available memory ranges:
SRAM size: 0x400 unused: 0x27 max hole: 0x24
error #10010: errors encountered during linking; "gpio_toggle_output_LP_MSPM0C1104_nortos_ticlang.out" not built
MSPM0C 시리즈는 SRAM이 1k 이다. ST와 비교해서 가격차이가 그렇게 많이 나는것도 아닌데… 왜 이렇게 하지?
printf 함수를 사용하면 여러 편리한점이 많지만 메모리 용량이 부족한 MCU에서는 사용하기에 어려움이 많은것 같다.
용량을 줄이는 다양한 방법이 많긴 하지만 우선 간단하게 테스트 할 수 있는 sprintf 함수로 테스트 해보자.
int put_str(const char* restrict s)
{
uint16_t i,len;
len = strlen(s);
for(i=0;i<len;i++)
{
DL_UART_transmitDataBlocking(UART_0_INST, s[i]);
}
return len;
}
int main(void)
{
unsigned char buf[20];
unsigned int cnt = 0;
SYSCFG_DL_init();
//printf("MSPM0C1104 UART Test\r\n");
while (1) {
delay_cycles(DELAY);
DL_GPIO_togglePins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN );
sprintf(buf, "%d\r\n", cnt++);
put_str(buf);
}
}