S32K144's Processor Expert project add 'printf()' function

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S32K144's Processor Expert project add 'printf()' function

3,440件の閲覧回数
baotingkai
Contributor II

I am using a new example 'hello_world_s32k144' form 'S32K14x EAR SDK v0.8.6' and it can work normally.

But when I add debug HardFault's code to the project,the project will be reported follow error:

pastedImage_1.png

When I comment on the 'printf' function, no error occurs.What is the cause of the error,the code as follow:

/*
* HardFault_Handler.c
*
* Created on: 2018_2_27
* Author: Ling
*/
#include "S32K144.h"
#include "s32_core_cm4.h"

void HardFault_Handler(void)
{

__asm("TST LR , #4");
/* LR Register & 0b0100 and Update the value in CPSR */
__asm("ITE EQ");
/* If LR's 2th bit equal to 0 */
__asm("MRSEQ R0 , MSP");
__asm("MRSNE R0 , PSP");
__asm("MOV R1 , LR");
__asm("B HardFault_Handler_C");

}

##

void HardFault_Handler_C(unsigned long *hardfault_args,unsigned int lr_value)
{
unsigned long int stacked_r0;
unsigned long int stacked_r1;
unsigned long int stacked_r2;
unsigned long int stacked_r3;
unsigned long int stacked_r12;
unsigned long int stacked_lr;
unsigned long int stacked_pc;
unsigned long int stacked_psr;
unsigned long int cfsr;
unsigned long int bus_fault_address;
unsigned long int memmanage_fault_address;


bus_fault_address = S32_SCB->BFAR;
memmanage_fault_address = S32_SCB->MMFAR;
cfsr = S32_SCB->CFSR;

stacked_r0 = ((unsigned long) hardfault_args[0]);
stacked_r1 = ((unsigned long) hardfault_args[1]);
stacked_r2 = ((unsigned long) hardfault_args[2]);
stacked_r3 = ((unsigned long) hardfault_args[3]);
stacked_r12 = ((unsigned long) hardfault_args[4]);
stacked_lr = ((unsigned long) hardfault_args[5]);
stacked_pc = ((unsigned long) hardfault_args[6]);
stacked_psr = ((unsigned long) hardfault_args[7]);


printf("[HardFalt report]\r\n");
printf("- Stack frame:\r\n");
printf("R0 = 0x%lx\r\n",stacked_r0);
printf("R1 = 0x%lx\r\n",stacked_r1);
printf("R2 = 0x%lx\r\n",stacked_r2);
printf("R3 = 0x%lx\r\n",stacked_r3);
printf("R12 = 0x%lx\r\n",stacked_r12);
printf("LR = 0x%lx\r\n",stacked_lr);
printf("PC = 0x%lx\r\n",stacked_pc);
printf("PSR = 0x%lx\r\n",stacked_psr);
printf("- FSR/FAR:\r\n");
printf("CFSR = 0x%lx\r\n",cfsr);
printf("HFSR = 0x%lx\r\n",S32_SCB->HFSR);
printf("DFSR = 0x%lx\r\n",S32_SCB->DFSR);
printf("AFSR = 0x%lx\r\n",S32_SCB->AFSR);

if(cfsr & 0x0080)
printf("MMFAR = 0x%lx\r\n",memmanage_fault_address);
if(cfsr & 0x8000)
printf("BFAR = 0x%lx\r\n",bus_fault_address);
printf("- Misc\r\n");
printf("LR/EXC_RETURN = 0x%x\r\n",lr_value);

while(1);


}

タグ(2)
8 返答(返信)

2,757件の閲覧回数
baotingkai
Contributor II

Thank  you for your answer,I have already solve the problem by change “Target Porcessor”->"Libraries support" ewl_c to newlib no I/O in "Project Properties".

Now I have a new ERROR about Processor Expert,the icon is gray and can not be loaded.

pastedImage_1.png

I have tried to use Build configurations explorer, it's not work.

pastedImage_2.png

And when I use the "PINS_DRV_Init" function in "pin_mux:PinSettings" Components .

pastedImage_3.png

The IDE crashes when it runs on pin 96 (PTC4),does anyone know the solution?

pastedImage_77.png

pastedImage_78.png

0 件の賞賛
返信

2,757件の閲覧回数
jiri_kral
NXP Employee
NXP Employee

Hi, 

I can't reproduce your issue. Can you please share your project? 

Jiri

0 件の賞賛
返信

2,757件の閲覧回数
baotingkai
Contributor II

Hi,Jiri

Thanks for help, I have uploaded the project to the attachment.Testing with S32K144EVB board.

@Jiri Kral

2,757件の閲覧回数
jiri_kral
NXP Employee
NXP Employee

Hi, 

I tested your project - and there is no issue on my machine. You can try to create new Workspace and import your project (File -> Import -> General -> Existing Project into Workspace). 

If it doesn't help - try to re-install S32DS. 

Hope it helps. 

Jiri 

0 件の賞賛
返信

2,757件の閲覧回数
baotingkai
Contributor II

Didn't work, but still thanks :-)

0 件の賞賛
返信

2,757件の閲覧回数
razva_tilimpea
NXP Employee
NXP Employee

Hi,

I suppose that you don't have clock enable for PORT C. Check clock manager configuration.

Best regards,

Razvan

2,757件の閲覧回数
jiri_kral
NXP Employee
NXP Employee

Hi, 

you need to write your own console event handlers. For inspiration you can look at this example:

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

Jiri

0 件の賞賛
返信

2,757件の閲覧回数
felixfeng
Contributor I

I think UART port should be connected with MCU and configured in your project. Then print your tager variable into serial tool.

In default way printf function is not supported in the the console of design studio.

0 件の賞賛
返信