10 years, 10 months ago.

LPC17xx.h no such file ... error on demo code

Hello,

I have been able to write, compile and run very limited programs on my Freescale KLZ25 to test the link and what not and all of that checks out. I need to access the one of the timers to do some accurate timing between event which happen over a period of about 0.1 microsecond so I would prefer to access a system clock directly as I have on other MCUs for the same task. Being new to the mbed enviroment and ARMs I looked for an example that uses a system clock directly.

I tried to compile the example titled TIMER0 example at http://mbed.org/users/microguy/notebook/timer0-example-code/ and got the error message "cannot source input file LPC17xx.h no such file or directory". Cam someone help me out and let me know what library, if any, I need to include.

Since I have chosen the Freescale board as my board I find it surprising that the IDE would try to compile in a header file for and LPC processor. The IDE is setup for the Freescale board as it has that board listed in the upper left corner of the IDE and small programs have compiled, linked and run on the Freescale board.

TIA wade

Here is the demonstration code I copied into my workspace and tried to comple.

#include "mbed.h"
#include "LPC17xx.h"
 
DigitalOut myled(LED1);
unsigned short timer_count;
 
extern "C" void TIMER0_IRQHandler (void)
{
if((LPC_TIM0->IR & 0x01) == 0x01)   // if MR0 interrupt, proceed
    {
    LPC_TIM0->IR |= 1 << 0;         // Clear MR0 interrupt flag
    timer_count++;                  //increment timer_count
    }
}
 
void timer0_init(void)
{
    LPC_SC->PCONP |=1<1;            //timer0 power on
    LPC_TIM0->MR0 = 2398000;        //100 msec
    LPC_TIM0->MCR = 3;              //interrupt and reset control
                                    //3 = Interrupt & reset timer0 on match
                                    //1 = Interrupt only, no reset of timer0
    NVIC_EnableIRQ(TIMER0_IRQn);    //enable timer0 interrupt
    LPC_TIM0->TCR = 1;              //enable Timer0
    pc.printf("Done timer_init\n\r");
}
 
 
int main (void) 
{
    myled = 0;
    timer0_init();
    timer_count = 0;
    
    while(1)
    {
        if (timer_count > 80)      //Set timer_count for about 8 seconds
            {
            if (myled == 1)             //If LED off, turn it on &
                {
                myled = 0;
                timer_count = 0;        //reset count
                }
            else
                {
                myled = 1;              //If LED on, turn it off &
                timer_count = 0;        //reset count
                }
            }
    }
}

1 Answer

10 years, 10 months ago.

Quote:

Since I have chosen the Freescale board as my board I find it surprising that the IDE would try to compile in a header file for and LPC processor

Thats also the problem, at the top of that program it specifically tries to include LPC17xx.h, while that isn't available for the Freescale board. Also the register names are specific for the LPC1768, thats the issue when you need direct access to hardware, it will be microcontroller specific.

Also it won't really do much accurate timing at that timescale. IIRC the Freescale board runs at 48MHz, so with a period of 0.1us we are talking about 4-5 clock cycles.

I understand the registers are going to be diferent, I guess the question should have been what should be included for the Freescale board, or does the Freescale version of mbed not allow direct access of the hardware?

Thanks wade

posted by wade brown 01 Jul 2013

Ah thats another question ;).

Answer: nothing. The include in this code also wasn't required. Maybe it was different in a very old version of the mbed library, but at least now you got all register names defined by including the mbed lib. Of course you need to reference manual of the KL25Z for the register names, and then they are defined here: http://mbed.org/users/mbed_official/code/mbed-src/file/3bc89ef62ce7/vendor/Freescale/KL25Z/cmsis/MKL25Z4.h. (That file is automatically included).

Timer seems to be around line 300. Should be something like:

TPM0->SC
posted by Erik - 01 Jul 2013