10 years, 9 months ago.

TIMER0 macros

Here is a bit of code that I wrote to test the use of TIMER0, using the TIMER0 macros defined in timers.h, the target board is a Freedom KL25Z

#include "mbed.h"

#include "timers.h"

Serial pc(USBTX, USBRX); // tx, rx

int main() {

  pc.printf("Starting Test!\n");
   
  TIMER0_INIT();
  TIMER0_START();
    while(1) {
     
        pc.printf("TIMER0_VALUE() = %d\n",TIMER0_VALUE());
    }
}

At first I got an error that the compler could not find LPC17xx.h so I commented out #include <LPC17xx.h> in mbeds_globals.h since I was using a Freedom KL25Z board then the compiler came back with the following errors:

"identifier "LPC_SC" is undefined" in file "/main.cpp", Line: 11, Col: 2 "identifier "LPC_TIM0" is undefined" in file "/main.cpp", Line: 11, Col: 2 "identifier "LPC_TIM0" is undefined" in file "/main.cpp", Line: 12, Col: 2

I assume this may have something to do with definitions that are missing that were in LPC17xx.h.

I am rather new to programming arms but have programmed 8-bit MCUs and computers in the past.

TIA wade

2 Answers

10 years, 9 months ago.

What is timers.h? From your errors I get it is an LPC1768 specific file, so that won't work for the KL25z

Timers.h is a part of Simplelib it looks like I assumed wrong when I thought that the macros defined in Simplelib would have had their definitions, register locations, etc. re-defined for the KL25Z.

On the other hand I am probably doing something stupid. I would prefer that to not being able to use a couple of Freedom boards that I have without going remapping the definitions in the files from the LPC boards to the Freedom boards.

Thanks wade

posted by wade brown 28 Jul 2013
wade brown
poster
10 years, 9 months ago.

Edit: place response in correct location.