AnsweredAssumed Answered

Hard fault caused by Processor Expert

Question asked by Mike Thomas on Jan 18, 2013

Hello all,


I am a new user of the Kinetis MCU's.

I am experimenting with the Freedom board.


I have created a simple program on the Freedom board which blinks the RGB leds. Initially, I created the project using "Device Initialization".

Using the Hardware Prespective, I setup the LED ports and the System Timer (SysTick). I then accidentally, clicked on the "DAC0" block in the IC outline, which immediatly generated the following code in the MCUInit module...



/* ### Init_DAC init code */ 


DAC0_C0 &= ( uint8_t)~(uint8_t)0xFBU;




DAC0_SR &= (uint8_t)~(uint8_t)0xFBU;


/* DAC0_DAT0L: DATA0=0 */


DAC0_DAT0L = (uint8_t)0x00U;


/* DAC0_DAT0H: DATA1=0 */

DAC0_DAT0H = (uint8_t)0x00U;




DAC0_C1 &= (uint8_t)~(uint8_t)0xE5U;




DAC0_C0 &= (uint8_t)~(uint8_t)0xFBU;


/* ### Init_DAC init code */ 



CMP0_DACCR = (uint8_t)0x00U;


The component inspector for the DAC shows that; pins, interrupts, and device initialization are disabled, however, code is ALWAYS generated when the  "Generate Code" button is clicked in the Hardware Prespective.


This in itself would not be a problem, except that apparently, a Hard Fault is generated when the first line of the DAC initialization code is executed.

     DAC0_C0 &= ( uint8_t)~(uint8_t)0xFBU;


According to the data sheet, this statement should do nothing more than leave the register as it was before it was called.

Commenting out the initialization code corrects the problem, and allows my test program to run fine.


The question is: what is this statement doing to cause a Hard Fault.


I have attached the entire MCUInit module which is causing the fault


Thanks in advance,








Original Attachment has been moved to: