Need printf() for MPC5675EVB

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

Need printf() for MPC5675EVB

2,674 Views
matthewclark
Contributor III

I'm trying to run a benchmark on my MPC5675EVB using the CW 2.10 SE tools for MPC55xx/MPC56xx.  After the calculations are completed, I want to print the results to the console, but my printf statement fails to link with

 

Link Error: undefined: InitializeUART

Project: MPC5675K_Test.mcp, Target RAM

Referenced from '__init_uart_console' in MSL_C.PPCEABI.base.V.UC.a

 

Link Error: undefined: ReadUARTN

Project: MPC5675K_Test.mcp, Target RAM

Referenced from '__read_console' in MSL_C.PPCEABI.base.V.UC.a

 

Link Error: undefined: WriteUARTN

Project: MPC5675K_Test.mcp, Target RAM

Referenced from '__write_console' in MSL_C.PPCEABI.base.V.UC.a

 

What am I doing wrong?  Am I failing to add a library?

 

Matt

Labels (1)
0 Kudos
10 Replies

1,607 Views
stanish
NXP Employee
NXP Employee

Ho Mohammed,

You need to add implementations of these functions into your project.

You can adjust and the files "uart.c" and "uart.h" from e.g. this example into your project:

https://community.nxp.com/docs/DOC-333894 

Hope it helps.

Stan

0 Kudos

1,607 Views
mohammedzakari1
Contributor I

thank you Stan, that helps,

0 Kudos

1,607 Views
admin
Specialist II

Hey Matthew,

You need to define the functions, preferably in a source file that's in your source path.

__init_uart_console()  // Initialize the uart (baud rate, pins, etc.)

__read_console()       // Read console; example: for ( count of specified bytes ) { wait until new char received; byte[i] = that char}

__write_console()       // Write console: for( all bytes in buffer ) { UARTD = byte[ i ]; wait for tx done }

Alternatively, if you don't want to bother with any UART setup, you can download CW 10.4 SE and use the ewl_c_hosted (a.k.a. "Debugger Console") option when you go through the new project wizard and are prompted for the I/O options.  This will send all printf output to the "Console tab". 

See also:

Re: Undefined InitializeUART, ReadUARTN, WriteUARTN

I hope thi helps,

-Rich

Note: the "SE" version of codewarrior restricts the size of code you can download, so just be forewarned about that.  From my experience, I've noticed that a C project including <stdio.h> will fit no problem, but a C++ project including the same header won't...

1,606 Views
stanish
NXP Employee
NXP Employee

Hello Matthew,

Attached are the files (uart.c, uart.h) that implements UART terminal low level functions.

You can use in in combination with CodeWarrior Classic project (MSL libraries). Simply include them into your project.

The UART init. requires Fsys set to 180MHz. If your clock is different you will need to adjust Init_LINFlex_0() function to get proper 115200 baudrate.

LINFlex0 is routed to upper SCI RS232 cannon connector.


Hope it it helps.


Stan


0 Kudos

1,606 Views
mohammedzakari1
Contributor I

Hi Stan,

can you elaborate more how and where you included these files to get the problem solved. 

I am facing the same issue, did anyone got the solution for the same please?

I am using CW 5.9.0 , powerPC platform. Below are the error... Need help

 

Link Error : undefined: 'InitializeUART'
Referenced from '__init_uart_console' in MSL_C.PPCEABI.bare.E.UC.a

Link Error : undefined: 'ReadUARTN'
Referenced from '__read_console' in MSL_C.PPCEABI.bare.E.UC.a

Link Error : undefined: 'WriteUARTN'
Referenced from '__write_console' in MSL_C.PPCEABI.bare.E.UC.a

 

Appreciated the help.

 

Thanks,

-Mohammed

0 Kudos

1,606 Views
matthewclark
Contributor III

Stan,

I was *finally* able to get to trying this code, but I seem to be running to a snag.  I'm crashing immediately when I run the following line:

static void Init_LINFlex_0 (void)

{

/* enter INIT mode */

LINFLEX_0.LINCR1.R = 0x0081; /* SLEEP=0, INIT=1 */

/* wait for the INIT mode */

while (0x1000 != (LINFLEX_0.LINSR.R & 0xF000)) {}

I'm not sure what its problem is, only that I immediately jump to IVOR1trap upon its execution.  I'm running my MPC5675KEVB board in LSM, but otherwise have not not changed any of its default settings.  Do you have any idea what could be going wrong?

Matt

0 Kudos

1,606 Views
stanish
NXP Employee
NXP Employee

Hello Matt,

I suspect this issue could be caused by the fact Mode Entry module is not correctly initialized on your side.

Can you double check the MCU enters Run mode and LIN module is enabled to be active in run mode?

e.g.:

  ...

  ME.RUNPC[0].R = 0x000000FE; /* enable peripherals run in all modes */

  ME.LPPC[0].R = 0x00000000;  /* disable peripherals run in LP modes */

/* Mode Transition to enter RUN0 mode: */

  ME.RUN[0].R = 0x001F00F0;              /* RUN0 cfg: 16MHzIRCON,OSC0ON,PLL0ON,PLL1ON,syclk=16M IRC */  

  ME.MCTL.R = 0x40005AF0;                /* Enter RUN0 Mode & Key */

  ME.MCTL.R = 0x4000A50F;                /* Enter RUN0 Mode & Inverted Key */    

  while (1 == ME.GS.B.S_MTRANS) {}       /* Wait for mode transition to complete */

  while(4 != ME.GS.B.S_CURRENTMODE) {};  /* Check RUN0 mode has been entered */

...

Stan

0 Kudos

1,606 Views
matthewclark
Contributor III

I pulled down the CW 10.4 SE and tried to create a new Bareboard Project, but I'm never offered I/O options, ewl_c_hosted or otherwise, in the wizard.  Is there another way to access them?

Matt

0 Kudos

1,606 Views
admin
Specialist II

Oh darn, maybe it's hardware specific.  For example, when working the Kinetis family of boards, there's this screen:

Ewl_hosted.jpg

Are you able to see this screen if you right click on your project and select properties?

If not, then I guess the UART route will have to be pursued.

I hope this helps,

Rich

1,607 Views
matthewclark
Contributor III

Rich,

No, alas.  I don't have a "Librarian" option, at least for the bareboard project I'm trying to create.  I guess I'll have to do it the hard way.  Thanks.

Matt

0 Kudos