Dependencies:   mbed

main.cpp

Committer:
manujose
Date:
2010-12-01
Revision:
0:820f75a424e8

File content as of revision 0:820f75a424e8:

#include "mbed.h"


Serial pc(USBTX,USBRX); 
DigitalOut myled(p19);
//InterruptIn ir(p29); 

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 |= (0x3 << 22);

//LPC_SC->PCLKSEL1 |= (1 << 13)
LPC_TIM2->TCR = 0x2;


LPC_PINCON->PINSEL0 |= (0xf << 8);
   
    //LPC_TIM2->CCR |= (1 << 4);  
    LPC_TIM2->CCR = 0x07;
LPC_PINCON->PINMODE0 |= (0x0A << 8);
   
    pc.printf(" pconp"); 
             // 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("\n %X",LPC_TIM2->TC); 
        myled = 1;
        //pc.printf("After Reset =  %X ",LPC_TIM2->TC); 
        
    }
}