direct timer register access

Status
Not open for further replies.

ossi

Well-known member
I want to directly access timer-registers on the teensy36. If I remove the two lines showHex(...) the program runs (prints every 0.5 seconds a ever increasing number).
If I want to access then _SC registers the call: showHex("TPM1_SC",TPM1_SC) ; works (prints a result). But if I use showHex("TPM2_SC",TPM2_SC) ; the program gets stuck (does not reach the line Serial.println("here 1"); ).

What do I make wrong. How can I access the timer registers ? Wich timer is used by FrequencyTimer2 ?



Code:
int led = 13;

#include <FrequencyTimer2.h>

void showHex(char *name,int val){
char helpString[32] ;
  sprintf(helpString,"%s = %08XH =%8dd \n",name,val,val) ;
  Serial.print(helpString) ;
  }

void setup() {
  pinMode(led, OUTPUT);
  Serial.begin(9600);
  delay(1000);
  Serial.println("start...");
  FrequencyTimer2::setOnOverflow(InterruptCode);
  FrequencyTimer2::setPeriod(500000);

  showHex("TPM1_SC",TPM1_SC) ;
  showHex("TPM2_SC",TPM2_SC) ;
  Serial.println("here 1");
  }

int intCount = 0;
int outCount=0 ;

void InterruptCode(void) {
  intCount++;
  digitalWrite( led, digitalRead( led ) ^ 1 );
  Serial.print(" ");
  Serial.print(intCount);
  outCount++  ;
  if(outCount>20){ outCount=0 ; Serial.println("//") ; }
  }

void loop() {
  }
 
Status
Not open for further replies.
Back
Top