Which pins for hardware counter?

02 Jun 2016

I need two hardware counters on the mbed LPC1768. I already use CAP2.0 on pin p30.

My code for CAP2.0 is

CAP2.0

    //enable PCTIM2
    LPC_SC->PCONP|=(1<<22);

    //SET P0.4 (p30)
    LPC_PINCON->PINSEL0|=((1<<8)|(1<<9));

    //configure counter
    LPC_TIM2->TCR   =0x2;//counter disable
    LPC_TIM2->CTCR  =0x3;//counter mode,increments on both edges
    LPC_TIM2->PR    =0x0;//set prescaler
    LPC_TIM2->CCR   =0x0;//Input Capture Disabled
    LPC_TIM2->TCR   =0x1;//counter enable

Correct me if I'm wrong: It isn't possible to use CAP2.1 completely seperate form CAP2.0. I need to take another timer.

In the mbed overwiew (https://developer.mbed.org/media/uploads/chris/mbed-005.1.pdf#3) I see that there are only CAP3.0 and CAP3.1 left, which are pinned out on the mbed. But in this thread (https://developer.mbed.org/forum/mbed/topic/383/) it says that TIMER3 is used for other things.

Is it possible to use one of these pins for another hardware counter which is completetly seperate from CAP2.x?