lpcware

sett_pll invokes HardFault Handler

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by masterboy on Thu Nov 21 06:37:48 MST 2013
Hi all,

I have a problem. I try program lpc812 and I would like to change cpu clock with IRC. I have simple example:


#ifdef __USE_CMSIS
#include "LPC8xx.h"
#endif

#include <cr_section_macros.h>

typedef struct _PWRD {
void (*set_pll)(unsigned int cmd[], unsigned int resp[]);
void (*set_power)(unsigned int cmd[], unsigned int resp[]);
} PWRD;

typedef struct _ROM {
const PWRD * pWRD;
} ROM;

ROM ** rom = (ROM **) (0x1FFF1FF8 + 3 * sizeof(ROM**));

unsigned int command[4], result[2];

int main(void) {

__disable_irq();
LPC_SYSCON->SYSPLLCLKSEL = 0;
LPC_SYSCON->SYSPLLCLKUEN = 0;
LPC_SYSCON->SYSPLLCLKUEN = 1;
LPC_SYSCON->SYSAHBCLKDIV = 1;
command[0] = 12000;
command[1] = 24000;
command[2] = 0;
command[3] = 0;
(*rom)->pWRD->set_pll(command, result);
__enable_irq();

    while(1) {
    }
    return 0 ;
}



This code still causes HardFault Handler, but I don't know why :( Help please.

Outcomes