lpcware

LPC_TIM2 hard fault on lpc1769

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by dragilla on Tue Aug 07 09:21:37 MST 2012
Hi,
I have a very simple program in which I isolated my problem. When I try to do anything with Timer 2 or Timer 3 on my board I get hard fault.
The code is as follows:


int main(void)
{
// P1[26] as cap0.0
PinCfg.OpenDrain = PINSEL_PINMODE_NORMAL;
PinCfg.Pinmode = PINSEL_PINMODE_PULLDOWN;
PinCfg.Funcnum = PINSEL_FUNC_3;
PinCfg.Portnum = PINSEL_PORT_1;
PinCfg.Pinnum = PINSEL_PIN_26;
PINSEL_ConfigPin(&PinCfg);

// P3[25] as mat0.0
PinCfg.Funcnum = PINSEL_FUNC_2;
PinCfg.Portnum = PINSEL_PORT_3;
PinCfg.Pinnum = PINSEL_PIN_25;
PINSEL_ConfigPin(&PinCfg);

// P1[18] as cap1.0
PinCfg.Funcnum = PINSEL_FUNC_3;
PinCfg.Portnum = PINSEL_PORT_1;
PinCfg.Pinnum = PINSEL_PIN_18;
PINSEL_ConfigPin(&PinCfg);

// P1[22] as mat1.0
PinCfg.Pinnum = PINSEL_PIN_22;
PINSEL_ConfigPin(&PinCfg);

// P0[4] as cap2.0
PinCfg.Portnum = PINSEL_PORT_0;
PinCfg.Pinnum = PINSEL_PIN_4;
PINSEL_ConfigPin(&PinCfg);

// P4[28] as mat2.0
PinCfg.Funcnum = PINSEL_FUNC_2;
PinCfg.Portnum = PINSEL_PORT_4;
PinCfg.Pinnum = PINSEL_PIN_28;
PINSEL_ConfigPin(&PinCfg);

// P0[23] as cap3.0
PinCfg.Funcnum = PINSEL_FUNC_3;
PinCfg.Portnum = PINSEL_PORT_0;
PinCfg.Pinnum = PINSEL_PIN_23;
PINSEL_ConfigPin(&PinCfg);

// P0[10] as mat3.0
PinCfg.Pinnum = PINSEL_PIN_10;
PINSEL_ConfigPin(&PinCfg);

// - CCR:CAP0RE = 1 - capture rising edge
// - CCR:CAP0FE = 0 - don't capture falling edge
// - CCR:CAP0I = 1 - generate interrupt
LPC_TIM0->CCR = 0b101;
LPC_TIM1->CCR = 0b101;
//LPC_TIM2->CCR = 0b101; // if I uncomment either of these 2 lines
//LPC_TIM3->CCR = 0b101; // I get a hard fault

while(1);

return 0 ;
}

If try to set CCR or PR or CTCR on TIM2 or TIM3 I get a hard fault.
What's going on? Please help.

ps: I'm attaching my whole test program.

Outcomes