AnsweredAssumed Answered

System Timer

Question asked by Rohan Anand on Jun 30, 2015
Latest reply on Jul 1, 2015 by Rohan Anand

I have written the following code to undergo dump debugging.The idea is to store the value of time and the PDOR register value in array.

#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 clear it

  SysTick->CTRL=0x00000050;//010

}

int main()

{

  unsigned long time[50];

  unsigned long data[50];

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

  InitLED();

  InitSYSTICK();

  last=SysTick->VAL;

  while(1)

  {

 

 

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

  if(i<50)

  {

  now=SysTick->VAL;

  time[i]=(last-now)&0x00FFFFFF;

  data[i]=PTD->PDOR;

  last=now;

  i++;

  }

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

  {}

  }

}

Led is not blinking.Code is compiling.I dont know if i am write in using the systick timer code syntax and the line data[i]=PTD->PDOR;

Please help me.

Outcomes