Problem using "sprintf"

Forum related to ERIKA Enterprise and RT-Druid version 3

Moderator: paolo.gai

Post Reply
antperlag
Newbie
Posts: 4
Joined: Mon Jun 10, 2019 2:18 pm

Problem using "sprintf"

Post by antperlag » Mon Jul 29, 2019 1:12 pm

Hello,

I am working with a S32K144 EVB and I have a problem when I include the function sprintf t the main function. I need this function to convert a uint to char, in order to send it by the UART as shown below:

Code: Select all

uint16_t inputCaptureMeas0 = 0;
    	char txBuff[255];
	inputCaptureMeas0 = FTM_DRV_GetInputCaptureMeasurement(INST_FLEXTIMER_IC1, 0U);
	sprintf(txBuff, "PWM frequency:\t%lu\tMeasured frequency:\t%u\t[Hz]\r\n", \
	                    flexTimer_pwm1_PwmConfig.uFrequencyHZ, inputCaptureMeas0);
	LPUART_DRV_SendData(INST_LPUART1, (const uint8_t *)txBuff, strlen((char *)txBuff));
	while(LPUART_DRV_GetTransmitStatus(INST_LPUART1, &bytesRemaining) != STATUS_SUCCESS);
When I build the project these problems appear in the console:

Code: Select all

c:/progra~2/gnutoo~1/4195f~1.920/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: erika3app.elf section `.text' will not fit in region `m_text'
c:/progra~2/gnutoo~1/4195f~1.920/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: section .data loaded at [20000000,20001353] overlaps section .text loaded at [1fff8400,200014b3]
c:/progra~2/gnutoo~1/4195f~1.920/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: region `m_text' overflowed by 5320 bytes
c:/progra~2/gnutoo~1/4195f~1.920/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status
make[1]: Leaving directory '/cygdrive/c/Users/antpe/OneDrive - UNIVERSIDAD DE SEVILLA/5 Software/BSW/bsw_s32k144_rt-druid/BSW/out'
make[1]: *** [/cygdrive/c/Users/antpe/ONEDRI~1/5SOFTW~1/BSW/BSW_S3~1/BSW/erika/mk/ee_arch_rules.mk:129: erika3app.elf] Error 1
make: *** [makefile:95: all] Error 2
Any idea why it happens?

Thanks in advance.

paolo.gai
Administrator
Posts: 875
Joined: Thu Dec 07, 2006 12:11 pm

Re: Problem using "sprintf"

Post by paolo.gai » Fri Aug 02, 2019 2:19 pm

sprintf is too big...

try writing a simple itoa function. I remember the original K&R C book had one.

Ciao,

PJ

Post Reply