This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC2294 How to program a counter

Hello everybody,

I have a Philips LPC2294/01 MC.

I would like to count the rise or falling edge from an external signal.

I have 2 questions and need your help!

1. Do my MC already have an external counter? I think so but I donÂ't reallyfound somethink about that.
2. And if not? How can I count an rise or falling edge with the internal timer/counter?

I hope somebody can help me? Maybe with some code to?

Thx!!!

Parents
  • Hi Per,

    this is me again.

    We can not really handle what you proposed us.

    But we try to catch our interrupts with an external interrupt input. We get the increments from a magnetic sensor on a north/south magnetic line. (hope that is the right translation!!)
    We want to try the counting with a slow speed. But our external interrupt doesnÂ't work.

    here is the code

    #include <stdio.h>
    #include <LPC22XX.H>
    
    #define VPBDIV_VAL  0x02
    
    __irq void eint3 (void) {
    
      IOCLR0 = 0x00000100;
      EXTINT = 0x00000003;
    
      VICVectAddr = 0x0000000;
    }
    void init_extern(void)
    {
            IODIR0 = 0x00000100;
    
      VPBDIV=0;
      EXTMODE = (1<<3);
      VPBDIV=VPBDIV_VAL;
      VPBDIV=0;
      EXTPOLAR = ~(1<<3);
      VPBDIV=VPBDIV_VAL;
      VICIntEnable = ( 1 << 17 );
      VICVectCntl2 = (0x20 | (1 <<17)) ;
      VICVectAddr2 = (unsigned)eint3;
      VICIntEnable = ( 1 << 17 );
    }
    
    int main (void)
    {
    
            PINSEL1 |= (1<<29);
            PINSEL1 &=~ (1<<28);
            init_extern();
    
    while (1)
            {
    
            }
    }
    

    this code shall only turn a LED on when an interrupt was detected on input P30.

    What is wrong?

    Maybe you or someone else can help us with it?

    Thanks a lot!

Reply
  • Hi Per,

    this is me again.

    We can not really handle what you proposed us.

    But we try to catch our interrupts with an external interrupt input. We get the increments from a magnetic sensor on a north/south magnetic line. (hope that is the right translation!!)
    We want to try the counting with a slow speed. But our external interrupt doesnÂ't work.

    here is the code

    #include <stdio.h>
    #include <LPC22XX.H>
    
    #define VPBDIV_VAL  0x02
    
    __irq void eint3 (void) {
    
      IOCLR0 = 0x00000100;
      EXTINT = 0x00000003;
    
      VICVectAddr = 0x0000000;
    }
    void init_extern(void)
    {
            IODIR0 = 0x00000100;
    
      VPBDIV=0;
      EXTMODE = (1<<3);
      VPBDIV=VPBDIV_VAL;
      VPBDIV=0;
      EXTPOLAR = ~(1<<3);
      VPBDIV=VPBDIV_VAL;
      VICIntEnable = ( 1 << 17 );
      VICVectCntl2 = (0x20 | (1 <<17)) ;
      VICVectAddr2 = (unsigned)eint3;
      VICIntEnable = ( 1 << 17 );
    }
    
    int main (void)
    {
    
            PINSEL1 |= (1<<29);
            PINSEL1 &=~ (1<<28);
            init_extern();
    
    while (1)
            {
    
            }
    }
    

    this code shall only turn a LED on when an interrupt was detected on input P30.

    What is wrong?

    Maybe you or someone else can help us with it?

    Thanks a lot!

Children
No data