AnsweredAssumed Answered

HardFault_Handler

Question asked by Rohan Anand on Jul 2, 2015
Latest reply on Jul 3, 2015 by Rohan Anand

I am writing the following code to store value in array of time and data.I am getting 2 warnings.

main6.c(17): warning:  #550-D: variable "time" was set but never used

        unsigned long time[50];

main6.c(18): warning:  #550-D: variable "data" was set but never used

        unsigned long data[50];

Code:-

#include "MKL46Z4.h"                    // Device header

void InitLED(void)

{

  SIM->SCGC5=SIM_SCGC5_PORTD_MASK;// Enable clock to PORTD

  PORTD->PCR[5]=256;// Set pin 5 of PORTD as GPIO

  PTD->PDDR=(1u<<5);// Set pin 5 of PORTD as OUTPUT

}

void InitSYSTICK(void)

{

  SysTick->CTRL=0;//Disable the systick timer

  SysTick->LOAD=0x00FFFFFF;//Reload it to its full value 24 bits

  SysTick->VAL=0;//Write something in current register to reset it

  SysTick->CTRL=0x00000005;//101

}

int main()

{

  unsigned long time[50];

  unsigned long data[50];

  unsigned long i=0,now=0,last=0,j=0;

  InitLED();

  InitSYSTICK();

  last=SysTick->VAL;

  while(1)

  {

   

    PTD->PTOR=(1u<<5);//Toggle LED

  if(i<50)

  {

  now=SysTick->VAL;

  time[i]=(last-now);

  data[i]=PTD->PDOR;

  last=now;

  i++;

  }

  for(j=0;j<=800000;j++)

  {}

  }

}

I dont know where i am going wrong.Please Help.

Outcomes