HardFault error

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

HardFault error

377 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by toniojesusde on Thu Apr 14 09:54:48 MST 2011
I have the next piece of code in my application. TIM2TCold is a global variable.
When I try to copy the contents of the counter/timer 2 from my timer0 handler i get a HARDFAULT! any ideas???

void TIMER0_IRQHandler(void) {//interrupt each second
    TIM2TCold=LPC_TIM2->TC;

many thanks,

Antonio
0 Kudos
6 Replies

366 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by toniojesusde on Fri Apr 15 03:54:57 MST 2011
CodeRedSupport, you were right. The initial configuration was right but some other part of my code overwrote the PCON and disabled it. Thanks a lot.
0 Kudos

366 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Apr 14 14:57:46 MST 2011

Quote: toniojesusde

When I try to copy the contents of the counter/timer 2 from my timer0 handler i get a HARDFAULT! any ideas???


Just to check the obvious, I presume that you have actually enabled Timer2 in PCONP?? On reset, Timer0/1 are enabled but Timer2/3 are disabled.

Regards,
CodeRedSupport
0 Kudos

366 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Thu Apr 14 14:49:03 MST 2011

Quote: Zero
Did you try to read in a dummy value, like:
volatile unsigned int dummy;
dummy=LPC_TIM2->TC;         



I understand the need for "volatile" here and in your previous post, but I'm curious about what a dummy read would accomplish?  Not knowing what the code is written as leaves us a bit in the dark.

Thanks
Larry
0 Kudos

366 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Apr 14 13:31:22 MST 2011

Quote: toniojesusde

unsigned int i, PIDOn, SetValCargaQ, CargaQSP, SetISP, Pulses, TIM2TCold;



Use:

volatile unsigned int i, PIDOn, SetValCargaQ, CargaQSP, SetISP, Pulses, TIM2TCold;

Does changing TIM2TCold cause something?

Did you try to read in a dummy value, like:
volatile unsigned int dummy;
dummy=LPC_TIM2->TC;         
0 Kudos

366 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by toniojesusde on Thu Apr 14 13:18:10 MST 2011
LPC1769

I do reset the interrupt

ISR works fine without that line

unsigned int i, PIDOn, SetValCargaQ, CargaQSP, SetISP, Pulses, TIM2TCold;

void TIMER0_IRQHandler(void) {//interrupt each second
    LPC_TIM0->IR = 1; /* clear interrupt flag */
    timer0_counter++;
    TIM2TCold=LPC_TIM2->TC;
0 Kudos

366 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Apr 14 10:03:49 MST 2011
Which MCU are you using?

Do you reset the timer interrupt?

Is your timer ISR working without this copy line?
0 Kudos