FRDM-KL05Z / MKL05Z32VFM4 Hard-fault with mbed ticker function

Showing results for 
Search instead for 
Did you mean: 

FRDM-KL05Z / MKL05Z32VFM4 Hard-fault with mbed ticker function

Contributor I



I am currently working with the Freescale FRDM-KL05Z development board. It features a MKL05Z32VFM4 IC with 32 KB flash & 4KB SRAM.


I am currently using the mbed libraries and I am using Keil to write and debug.


The current memory location/size:

IROM1: start: 0x0 Size: 0x800

IRAM1: start: 0x1FFFFC00 size: 0x400

IRAM2: start: 0x20000000 size: 0xC00



The problem:

The mbed libraries feature a 'ticker' which I am using to create a sample rate. However to ensure that it is continuously sampling, on this occasion I have created a square wave which is being outputted to the DAC.


The code works well when it runs. I can increase the sample time and it still works well. The problem arises when I try to debug the firmware. The code starts and the square wave output is as expected. When I stop/pause the program a hardfault is produced and the debug has to be terminated.

If I use a simple for loop in place of the ticker it can be started and stopped until the cows come home (however I cant use a for loop on this occasion.. the ticker is a must).

Has anyone expereienced this problem? What could be causing this hardfault? If so... please help!


#include "mbed.h"

#define SAMPLE_RATE  0.250           // samples the data ready every 250ms


Ticker SAMPLE_DETECTOR;                

AnalogOut DAC_Out_Pulse(PTB1);


int data_ready_pulse = 0;

int y = 0;

int i = 0;




     data_ready_pulse = 1;



int main(void)



     while (1) {

     if (data_ready_pulse){

          data_ready_pulse = 0;


     if (!y){

          y = 1;





          y = 0;







Best regards,



Labels (1)
0 Kudos
0 Replies