Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- gpushkar
- Date:
- 2010-12-01
- Revision:
- 0:62595848abf2
File content as of revision 0:62595848abf2:
#include "mbed.h"
Serial pc(USBTX,USBRX);
DigitalOut myled(LED1);
InterruptIn ir(p21);
extern "C" void Timer2_IRQHandler(void) {
pc.printf("hello %X", LPC_TIM2->CR0);
LPC_TIM2->IR = 0xff;
}
int main() {
//CONFIGURE PIN FOR CAP2:0
LPC_SC-> PCONP |= (1 << 22);
LPC_PINCON->PINSEL1 |= (0xf<<8);
pc.printf(" pinsel1");
//LPC_TIM2->CCR |= (1 << 4);
LPC_TIM2->CCR = 0x07;
pc.printf(" ccr" );
// Power on Timer2
pc.printf(" pconp");
LPC_TIM2->TCR = 0x2; // Reset and set to timer mode
//LPC_TIM2->CTCR = 0x0;
//LPC_TIM2->PR = 0; // No prescale
//LPC_TIM2->MR0 = 0xF0537000 ; // Match count for 100mS
//LPC_TIM2->MCR = 3; // Interrupt, Stop, and Reset on match
LPC_TIM2->TCR = 1; // Enable Timer0
// Enable the ISR vector
// NVIC_SetVector (TIMER2_IRQn, (uint32_t)&Timer2_IRQHandler);
//NVIC_EnableIRQ(TIMER2_IRQn);
pc.printf("timers set");
while(1) {
myled = 1;
ir.mode(PullUp);
wait(1);
pc.printf("b4 Reset = %X ",LPC_TIM2->TC);
ir.mode(PullDown);
myled = 0;
wait(1);
//LPC_TIM2->TC = LPC_TIM2->TC ; ;
ir.mode(PullUp);
pc.printf("After Reset = %X ",LPC_TIM2->TC);
}
}