AnsweredAssumed Answered

ARM Cortex-M4 K60N512 - Hard Fault

Question asked by Craig Laubscher on Mar 24, 2012
Latest reply on Mar 24, 2012 by Craig Laubscher

I am comming from the smaller 8/16 bit microcontrollers from Microchip and Atmel, and I got to say things have gone smoother. None the less I am trying. Anyway, I decided to write in pure C rather than a mix of assembly and C thinking it'd smooth the process. Anyway, I seem to keep running into a problem and I am not exactly sure of the issue. I am just trying to get used to the peripherals that the microcontroller comes with. The problem is that it keeps jumping me to isr_default and I am trying to track down the problem. In assembly, I noticed this would occure when a 32-bit encoded instruction gets executed in a word misaligned address (not data relavent). I figure this is probable, only word aligned instructions for 32-bit encoded ones. What I was suprised by is that the compiler generates what I thought was misaligned code too. Not sure what to make of it. The following is just a bit of code I have been dabbling with. I just think I am starting to get lost in the documentation... I have 7 PDFs open currently, and I think I am mixing them up. Thank you for your time.


#include "derivative.h"void main(){ //================================================== // setup hardware //================================================== // Configure Clock //MCG_C2 |= MCG_C2_IRCS_MASK; //MCG_C1 = (MCG_C1 & MCG_C1_CLKS_MASK) + (0x1 << MCG_C1_CLKS_SHIFT);   // Configure GPIO SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK; PORTC_PCR18 = PORT_PCR_MUX(0x1); GPIOC_PDDR = (1 << 18);  // Configure PIT PIT_MCR = 0x0; PIT_LDVAL0 = 0xF4240; PIT_TCTRL0 = (0 << PIT_TCTRL_TIE_SHIFT) | (1 << PIT_TCTRL_TEN_SHIFT);  //================================================== // loop //================================================== while(1) {  if(PIT_TFLG0 & PIT_TFLG_TIF_MASK)  {   PIT_TFLG0 |= PIT_TFLG_TIF_MASK;   GPIOC_PTOR |= (1 << 18);  } }}// these seem to not get called... oh well.void HardFault(){ __asm("nop");}void MemFault(){ __asm("nop");}void BusFault(){ __asm("nop");}void UsageFault(){ __asm("nop");}


Let me make note I am using CodeWarrior 10.1.