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:
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);
}
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.
I have tried to use Build configurations explorer, it's not work.
And when I use the "PINS_DRV_Init" function in "pin_mux:PinSettings" Components .
The IDE crashes when it runs on pin 96 (PTC4),does anyone know the solution?
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
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.