Default ISR KL25Z Problem

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

Default ISR KL25Z Problem

1,541 Views
saul_2510
Contributor I

Hi, i'm developing an application for the FRDM-KL25Z in baremetal without Processor Expert, where i use some peripherals such as ADC, GPIO, SPI, I2C, PIT, LPTMR, Systick all of them with interrupts, i have configured as it's required the clock gating for every peripheral, and i have wrote every ISR, but in some pieces of code it get stucked in the default ISR, and i don't know why, the problem occur when some function execute, but the weird part of this is when i change the order of the functions and sometimes works.

 


I have disabled all the breakpoints, even i've updated the firmware of the debugger (USB openSDA), but it doesn't works, i was thinking that the problem were the priorities of the interrupts, another reason that i think is that can occur it when i'm inside in some ISR and another Interrupt occur, but i have readed that the NVIC can pre-empt, so i dont' really have idea why it is happening.

 

I apreciate any help.

 

Saul.

Original Attachment has been moved to: SourceFiles.rar

0 Kudos
9 Replies

1,006 Views
saul_2510
Contributor I

Hi Kerry, here it is the whole project, the problem is in the following functions, placed in the file RF.c 

bool sendPacket(uint8 len, RFDataCmd cmd ,uint8* buf)
{
if(RF_Status != RF_Busy)
{
if(RF_Status != RF_AsTx)
{
RF_LastStatus = RF_Status;
RF_StartTx();
}
uint8 packet[32], index;

packet[0] = 0xFE;
packet[1] = len;
packet[2] = cmd;
for(index = 1 ;index < len; index++)
{
packet[2+index] = buf[index];
}
packet[2 + index] = 0xEF;
delay_ms(10);
RF_writePayload(&packet[0], len+3 , W_TX_PAYLOAD);
delay_ms(10);
if(RF_LastStatus == RF_AsRx)
{
RF_LastStatus = RF_Status;
RF_StartRx();
}
return False;
}
else
return True;
}

void RF_StartTx(){
uint8 reg = 0;
RF_Status = RF_AsTx;
//Store the actual CONFIG
RF_readRegister(CONFIG,&reg,1);
while(getSPIStatus() != SPI_Available);
//Turn off the PRIM_RX and write it
reg &= ~PRIM_RX;
RF_writeRegister(CONFIG,&reg,1);
while(getSPIStatus() != SPI_Available);

CE(ON);
//Tx Delay required
delay_ms(200);
}

Thank you for your help! 

0 Kudos

1,006 Views
saul_2510
Contributor I

Hello Kerry, yes the problem was caused by the SPI.
I was using KDS 3.2 and i decide to move my project to MCUXpresso. There it gives a HardFault, and it happens only in the Function sendPacket but only the second time that i want to use it, this function works with the SPI, but when the ISR finish his work and want to return, it give me the HardFault, In this moment i'm unable to send you a picture, but i apreciate your help, in the next hours i'll try to take the picture and post it!

Thank you,

Saul

0 Kudos

1,006 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Saul,

  Just as my first reply, please check which detail code line caused the HardFault, function sendPacket is too big, it is difficult to locate the problem.

Have a great day,
Kerry

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,006 Views
saul_2510
Contributor I

I was making tests yesterday, and i saw that the problem is when i try to write the array named packet placed in the function sendPacket as follow: 

uint8 packet[32], index;

packet[0] = 0xFE;
packet[1] = len;
packet[2] = cmd;

When i got there i try to execute it, gives me the Hard Fault. 

Saul. 

0 Kudos

1,006 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Saul,

   What the IDE you are using?

   I can't use the KDS open your project, I need to check it on my side.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,005 Views
saul_2510
Contributor I

Hi Kerry i'm using MCUXpresso.

I'll attach again the project files hoping it helps you.

Thank you for your help!

Saul.

0 Kudos

1,005 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Saul,

   After checking your code, I locate the detail function line which caused the hardfault.

pastedImage_2.png

pastedImage_1.png

The main problem is:

status = SPI_Op(sequence,buf,(len+ 1),0);

When SPI_Op return back, the returned data is 2, and when 2 gives to status, the hardfault happens.

The according asm code is :

00001e48:   movs    r3, r0

00001e4a:   strb    r3, [r4, #0]

So, that's really very strange, I am still working on it.

Any updated information, will let you know.
Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,005 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Thank you for your updated information.

  What's the detail line in your code caused the problem, did you locate the specific point?

  Please give the picture which shows the problem when you debug it.

  Besides, I find you are using the SPI module, whether the problem caused by the SPI?


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,005 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Customer,

    The code you have attached is not the project, it is the source code, I can't find the root problem directly, because you didn't tell me which function will enter ISR.

    You can post some functions or line of code which will cause the default ISR problem.

    I don't know whether you link your ISR function in your problem.

    You can refer to this post:

Debugging Hard Faults on ARM Cortex-M | MCU on Eclipse 

Find which code caused your problem, then let me know.

Besides, please check your IDE optimization, please configure it to none.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos