MPC5748G error when building

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

MPC5748G error when building

4,636 Views
huqiang
Contributor IV

Hello,

Recently, I try to use the function "printf()" in the MPC5748G project in S32 DS, but it always became error: printf.c undefined reference to '_pformatter' , as the figures below shown:

143591_143591.PNG2.PNG

143563_143563.PNGCapture.PNG

and I already added "stdio.h" .

143592_143592.PNG3.PNG

Is there any configurations that I made wrong ?

Please help me to deal with this problem.

Thank you!

Labels (1)
16 Replies

2,721 Views
yalamandadosaky
Contributor V

b55689​,Vinchev Aleksandar

Where can i call this config_sci and what is the speed value can i pass .

where can i call the write_char function, is it required ?

0 Kudos

2,721 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

please look at the following project. I use there printf function. Project is for MPC5775K, but for MPC5748G it will be the same.

Example MPC5775K PinToggleStationery S32DS

Regards,

Martin

2,721 Views
yalamandadosaky
Contributor V

Hi Martin Kovar,

Can you please help me what is the fsys value for baud rate calculation(LINFlex_D_2 asUART) for MPC5748G,e200-z4.Which documentation is helpful for the knowing the LINFlex_D_? need to be configure for the mpc5748g uart.c file .

0 Kudos

2,721 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

About document, please look at the following User guide.

http://cache.nxp.com/files/microcontrollers/doc/user_guide/MPC5748GEVBUG.pdf?fsrch=1&sr=4&pageNum=1

If you want to calculate baud rate, you have to know F80 frequency, which is source clock for LINFlexD. Look at the reference manual chapter 9.4.3.3

Formula for baud rate calculation is:

LDIV = fperiph / (16 * desired baudrate)

LINFBRR = 16 * fractional part of LFDIV (after decimal point)

for example if F80 = 80MHz and required baud rate is 19200b/s:

LFDIV = 80MHz/(16*19200) = 260,416

LINIBRR = 260

LINFBRR = 16*0.416 = 7

Regards,

Martin

2,721 Views
yalamandadosaky
Contributor V

@Hi Martin,

I am working with NXP MPC5748G I did all the above except LINFlexD_0_Init function in uart.c , SIUL2 pad configuration, and also  baudrate according you clock settings. Compilation done.But Execution was crashed .

why and how to  configure LINFlexD_0_Init function in uart.c and  SIUL2 pad configuration.

0 Kudos

2,721 Views
alexvinchev
Contributor V

Please be advised that in the following code comments might not be correct, but the code itself is working.

// General defines

#define SSS_OFFSET      512

#define UARTLIN_MSCR0   (712 - SSS_OFFSET)

// LinFlex0@ PB2/PB3

#define UARTNUM         0

#define UARTLIN         LINFlexD_0

#define UARTLIN_TXGIO   PB2     // #define  PB2            18

#define UARTLIN_TXSSS   1

#define UARTLIN_RXGIO   PB3     // #define  PB3            19

#define UARTLIN_RXSSS   2

void config_sci(uint32_t speed)

{

    uint32_t prediv;

    // clear buffers

    //memset( &sci_rx_buffer[0][0],0,SCI_RX_BUFER_LINES*SCI_RX_BUFER_CHARPERLINE );

    //memset( &sci_tx_buffer[0][0],0,SCI_TX_BUFER_LINES*SCI_TX_BUFER_CHARPERLINE );

    // config LINLFEX

    UARTLIN.LINCR1.B.SLEEP       = 0; // LINFLEX in init mode

    UARTLIN.LINCR1.B.INIT        = 1; // LINFLEX in init mode

    UARTLIN.UARTCR.B.UART        = 1; // UART

    UARTLIN.UARTCR.B.TDFL_TFC    = 0; // 1byte buffer  //change!

    UARTLIN.UARTCR.B.RDFL_RFC    = 0; // 1byte buffer

    UARTLIN.UARTCR.B.RFBM        = 0; // Rx buffer-mode

    UARTLIN.UARTCR.B.TFBM        = 0; // Tx buffer-mode

    UARTLIN.UARTCR.B.RxEn        = 1; // rx enable

    UARTLIN.UARTCR.B.TxEn        = 1; // tx enable

    UARTLIN.UARTCR.B.PC1         = 0; //

    UARTLIN.UARTCR.B.PC0         = 0; //

    UARTLIN.UARTCR.B.PCE         = 0; // no Parity

    UARTLIN.UARTCR.B.WL1         = 0; // 8bit data

    UARTLIN.UARTCR.B.WL0         = 1; // 8bit data

    // Pre-division

    if (UARTNUM == 0) {

        // Special case, LIN 0 clock is F40(40MHz), not F80(80MHz)

        // UARTLIN(0) => F40    | 40MHz / speed

        prediv = 40000000 / speed;

    } else {

        // UARTLIN(1-17) => F80 | 80MHz / speed

        prediv = 80000000 / speed;

    }

    // FBRR = Fxx / speed / 16, fraction part only

    UARTLIN.LINFBRR.R = (uint16_t)(prediv & 15);   /* Fractional divider.      */

    // IBRR = Fxx / speed / 16, integer part only

    UARTLIN.LINIBRR.R = (uint16_t)(prediv >> 4);   /* Integer divider.         */

    UARTLIN.LINCR1.B.INIT = 0; // LINFLEX in init mode

    UARTLIN.LINIER.B.DRIE = 1; // enable SCI.RX interrupt

    UARTLIN.LINIER.B.DTIE = 1; // enable SCI.TX interrupt

    /* LINx_TX */

    SIUL2.MSCR[UARTLIN_TXGIO].B.OBE = 1;

    SIUL2.MSCR[UARTLIN_TXGIO].B.SSS = UARTLIN_TXSSS ;

    /* LINx_RX */

    SIUL2.MSCR[UARTLIN_RXGIO].B.OBE  = 0;

    SIUL2.MSCR[UARTLIN_RXGIO].B.IBE  = 1;

    SIUL2.IMCR[UARTLIN_MSCR0 + UARTNUM].B.SSS = UARTLIN_RXSSS ;

}

void write_char(char value)

{

    UARTLIN.BDRL.B.DATA0 = value;

    do {} while ( UARTLIN.UARTSR.B.DTFTFF == 0 );

    UARTLIN.UARTSR.R = 0x00000002;               // clear DTF bit, only

    if ( value == '\n' ) write_char('\r');

}

0 Kudos

2,721 Views
yalamandadosaky
Contributor V

Which LINFlex_D_? is to be configure for MPC5748G and why we need to configure SILU2.

0 Kudos

2,721 Views
alexvinchev
Contributor V

You have asked for LinFlex0, so... code above is for 0, you can change this part to adapt to whatever LinFlex your MCU is supporting:

#define UARTNUM        0

#define UARTLIN        LINFlexD_0

#define UARTLIN_TXGIO  PB2    // #define  PB2            18

#define UARTLIN_TXSSS  1

#define UARTLIN_RXGIO  PB3    // #define  PB3            19

#define UARTLIN_RXSSS  2

Regarding SIUL2, I'll highly suggest that you read whole Reference Manual of your MCU. From your questions I could guess that you never used or programmed for embedded system...

0 Kudos

2,721 Views
yalamandadosaky
Contributor V

Hi Aleksandar,

Yes I am fresher ,new to embedded system,main thing is we are supportiing one person who is in U.S and he has all board setup, we dont have any board setup and all.Can you help me to sort out the problem for printf .

board set up is MPC574xG MB and MPC5748G 176DS,I dont know which LINFlexD_? is using but I reffered AN4830  for MPC5748G there it mentioned that LINFlexD_2 and Freq is F80 .

One more thing i want ask you what is the value of speed.

Plz can you help me

Thanks in Advance.

0 Kudos

2,721 Views
alexvinchev
Contributor V

Hi, yalamandadosakyala​,

first, regarding SIUL (System Interface Unit Lite)... In embedded systems it is common to have multiple functions per pin, since devices have broad functionality and limited pin count. This requires that pin should be configured to serve certain functionality and this is done thru set of multiplexers or other kind of configuration matrix. Pin configuration in case of Qorivva devices is done through SIUL. If you wonder what SIUL is, there is nice answer from lukaszadrapa​ here: What is SIUL?

Then, regarding MPC5748 evaluation board... If you (or someone) would like to use built in UART to USB convertor (FTDI chip, drivers have to be installed prior usage), LinFlexD_2 should be used, since this one is routed to the convertor on the board.

I'm attaching here printf example, running on X-MPC574xG-MB + MPC574XG-256DS hardware. It is prepared for GHS compiler and Trace32 debugger (you have .cmm scripts inside). I kept also compiled binaries, so they could be directly flashed to the target. There are two projects and two outputs created - X-MPC574XG-MB-GHS-C1-DEMO.gpj & bin/MPC5748G_CUT1 are for 0N65H devices, X-MPC574XG-MB-GHS-C2-DEMO.gpj & bin/MPC5748G_CUT2 are for 1N81M devices.

This demo should run also on 176pin MCU without modification (at least this is what shows me quick review of Rev.4 IO_Signal_Description_and_Input_multiplexing_tables.V3.0.1.xls document).

Output from the example should be something like:

*******  MPC5748G loop 273 ******

*******  MPC5748G loop 274 ******

*******  MPC5748G loop 275 ******

When X-MPC574xG-MB board is connected to the PC, it brings two COM ports (let say COM14 & COM15). Higher port should be used (i.e. COM15), speed is 115200bps, 8bit data, no parity.

Actually, in the attached example you'll find code I've pasted above, but as complete project...

Good luck!

2,720 Views
yalamandadosaky
Contributor V

Hi,I made all the changes,but output is not getting on UART I don't know why it is not working.

We are using mpc574xg -mb which is running micrium rtos on nxp board with mpc5748-176ds .

One doubt is how printf will call read_console,write_console functions in UART_console_io.c

0 Kudos

2,720 Views
martin_kovar
NXP Employee
NXP Employee

Hi,yalamandadosakyala​,

unfortunately, I have no experience with micrium rtos, but if I were you, I will try the following steps:

1) When you call printf function, you should not get any IVOR or get stuck somewhere in printf function code.

2) If the first step is OK, you should check, if you have some data in LinFLex2_BDRL_DATA0 register.

3) If also second step is OK, there is some problem with I/O pads. The problem could be some PAD misconfiguration.

4) Check other parameters like baud rate, number of data bits, parity, stop bits and flow control.

I checked package schematic and I found pads on your package are correctly routed to mother board so there should not be any problem.

What is the second side you communicate with? Is it PC? Please realize, you have to use USB to interconnect with second device, because on NXP EVB there is not independent RS232 transceiver.

Regards,

Martin

2,720 Views
alexvinchev
Contributor V

yalamandadosakyala​, I could only guarantee that example works for BGA256 package and without OS. We are not interested in lower pin count/simpler MPC5748G devices, so I don't have them. I've evaluated only ChibiOS on this platform and it works as well in my setup, but I'm not sure if I can provide example, based on ChibiOS.

For your actual setup you should find what is wrong and why something is not working.

MPC5748G is quite complex device and you could easily miss something crucial, so check carefully your setup.

I'd recommend you to try to put this example as is and then if it is working, look what blocks it in final setup. If it is not working as is provided, then you have other problems with your setup... Check also if J16 jumper is set in a way to connect FTDI to MPC, this could be also a reason to have non-working setup... You could loop back TX to RX of FTDI to check if you are opening the correct COM port.

0 Kudos

2,720 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

add this option to the linker flags:

-Xlinker --undefined=__pformatterFP -Xlinker --defsym=__pformatter=__pformatterFP

pastedImage_2.png

Now it will work.

Regards,

Martin

2,720 Views
huqiang
Contributor IV

Thank you very much!

But after I added the linker flags, it still have a error and this error even have no explanation

4.PNG

If I do not use the function "printf()", this error will disappear.

It seems that I still need to change something?

0 Kudos

2,720 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

add the files in the attachment to your project. Do not forget include stdio.h library in file, where you call printf function, C files to src folder and H file to include folder.

But you have to modify LINFlexD_0_Init function in uart.c. There is SIUL2 pad configuration, and you also have to set baudrate according you clock settings.

Regards,

Martin