Jump to content
Sign in to follow this  
madias

Little helper script: Which timer is in use (Timer,Wtimer,Watchdog)?

Recommended Posts

Hello,

as I was studying the (extremely good written!) driverlib documentation, i noticed the SysCtlPeripheralReady function.

Because it is not always clear which Timer (TIMER,WTIMER,WATCHDOG) is currently in use (many of them are used with PWM and other stuff), I wrote this little helper sketch for my Tiva C.

The definitions for other peripheral  can be read in "sysctl.h", I only used the timers to keep it short.

I also included the SysCtlPeripheralPresent function, but I think it is meant, that a peripheral is physically available, so the "ready" function is the key. Try it out with some line of code with PWM stuff (with different pins) for example and see the difference!


/*
Little timer state helper
 no (c) by Matthias Diro
 */
#include <stdint.h>
#include <stdbool.h>
#define PART_TM4C123GH6PM
#include "inc/tm4c123gh6pm.h"
#include "driverlib/sysctl.h"

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.println("---Timertest---");
  Serial.println("***Timer***");  
  for (int x=0;x<=5;x++)
  {
    Serial.print("Timer: ");    
    Serial.print(x);
    Serial.print(" present: ");
    Serial.print(SysCtlPeripheralPresent(4026532864+x));
    Serial.print(" ready: ");
    Serial.println(SysCtlPeripheralReady(4026532864+x));
  }
  Serial.println("***WTimer***");
  for (int x=0;x<=5;x++)
  {
    Serial.print("WTimer: ");    
    Serial.print(x);
    Serial.print(" present: ");
    Serial.print(SysCtlPeripheralPresent(4026555392+x));
    Serial.print(" ready: ");
    Serial.println(SysCtlPeripheralReady(4026555392+x));
  }
  Serial.println("***Watchdogs***");
  for (int x=0;x<=1;x++)
  {
    Serial.print("Watchdog: ");    
    Serial.print(x);
    Serial.print(" present: ");
    Serial.print(SysCtlPeripheralPresent(4026531840+x));
    Serial.print(" ready: ");
    Serial.println(SysCtlPeripheralReady(4026531840+x));
  }
  Serial.println();

  while(1);
}

Maybe this little code helps some of you!

 

Regards

Matthias

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...