lpc1769 timer count + interrupt gpio

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

lpc1769 timer count + interrupt gpio

1,934件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Thu Apr 28 05:48:58 MST 2011
I am trying to read a signal from my receiver.
The signal looks similar to: http://gallery.mikrokopter.de/main.php/v/tech/TEK0004.JPG.html

The signal has 8 channels. I can read each channel value by reading the time between each rising edge.
The lower signal is not longer then 0.42ms
Each channel can have a signal between 0.5ms and 1.5ms
The pause is greater then 1.6ms

The problem i now have, the counter does not have a higher value then 1 or 2.
I even set the interval_timer to 1.

I made an interrupt on gpio 0.15
 /* SystemClockUpdate() updates the SystemFrequency variable */
      SystemClockUpdate();

      // Enable all interrupts
      __enable_irq();
      // Set P0_22 to 00 - GPIO
      LPC_PINCON->PINSEL1 &= (~(3 << 12));
      // Set GPIO - P0_22 - to be output
      LPC_GPIO0->FIODIR |= LED1;
      // Set GPIO p0-15 intput
      LPC_GPIO0->FIODIR |= RC;
      //Set interrupt on pin 0-15 rising edge
      LPC_GPIOINT->IO0IntEnR |= (1 << 15);


      //Set timer vor RC information
      init_timer(0,1);
      //Enable the timer
      enable_timer(0);
      //
      NVIC_EnableIRQ(EINT3_IRQn);
void EINT3_IRQHandler (void)
{
    if ((LPC_GPIOINT->IO0IntStatR & (1 << 15)) == (1 << 15))
      {
        //Put led on to tell us we got an interrupt
        LPC_GPIO0->FIOSET = LED1;
        //Goto sub routine
        RC_interrupt();
        //raising edge interrupt on pin 0.15 was fired
        LPC_GPIOINT->IO0IntClr |= (1 << 15); // clear the status
        //Return where we came from
        return;
      }
}
void RC_interrupt()
{
    if((timer0_m0_counter > 0) && (timer0_m0_counter < 45))
        {
            //pauze tijd niets doen.
            //pause time should be between 0 and 0.42ms
        }
        else if((timer0_m0_counter > 50) && (timer0_m0_counter < 220))
        {
            //The real signal should be between 0.5ms to 1.5ms
            switch(teller_signaal)
            {
                case 0:
                    timer_1 = (timer0_m0_counter - OFFSET2);
                    break;
                case 1:
                    timer_2 = (timer0_m0_counter - OFFSET);
                    break;
                case 2:
                    timer_3 = (timer0_m0_counter - OFFSET2);
                    break;
                case 3:
                    timer_4 = (timer0_m0_counter - OFFSET2);
                    break;
                case 4:
                    timer_5 = (timer0_m0_counter - OFFSET);
                    break;
                case 5:
                    timer_6 = (timer0_m0_counter - OFFSET);
                    break;
                case 6:
                    timer_7 = (timer0_m0_counter - OFFSET);
                    break;
                case 7:
                    timer_8 = (timer0_m0_counter - OFFSET);
                    break;
            }
            teller_signaal++;
        }
        else if(timer0_m0_counter > 200)
        {
            //nothing signal is > 1.6ms
            //niets doen
            //Teller op 8/9 zetten deze met elke else if 45> <200 met 1 verlagen. En waarde opslaan in goede timer.
            teller_signaal = 0;
        }
    timer0_m0_counter = 0;
    timer0_m1_counter = 0;

        return;
}




If this: #define TIME_INTERVAL_RC    (9000000/1000 - 1) /is 1ms, do i  need to increase or decrease 1000 to get it to 10us for example?
I can not find what the problem could be, the interrupt is working.
Hope you can help me with this.

Lithium
0 件の賞賛
返信
7 返答(返信)

1,606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Thu May 26 02:01:00 MST 2011
Thank you very much :)
0 件の賞賛
返信

1,606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Wed May 25 11:29:27 MST 2011

Quote: Zero
Use Capture register: CR0 / CR1



Good answer.  [B]I'm[/B] reading UM10360 chapter 6[B] again[/B].:)

Thanks,
Larry
0 件の賞賛
返信

1,606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 25 10:56:57 MST 2011
Use Capture register: CR0 / CR1

Quote:

Capture Register 0. CR0 is loaded with the value of TC when there
is an event on the CAPn.0(CAP0.0 or CAP1.0 respectively) input.

0 件の賞賛
返信

1,606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Wed May 25 10:26:30 MST 2011

Quote: Lithium
I now would like to use the input capture.
I got the input capture interrupt working, i can't find the register with the time value.
Where can i read the timer value?



UM10360 chapter 21 table 425.  TC - Timer Counter.  You may have to deal with overflow of the counter so read this chapter throughly.  Also see the CCR - Count Control Register section.
0 件の賞賛
返信

1,606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Wed May 25 03:56:06 MST 2011
I now would like to use the input capture.
I got the input capture interrupt working, i can't find the register with the time value.
Where can i read the timer value?
0 件の賞賛
返信

1,606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Sat Apr 30 03:01:40 MST 2011
I have found an solution.
I modefied the timer.c file function init_timer:
    LPC_TIM0->MR0 = mS interval * 10; /*
    LPC_TIM0->MR1 =mS interval * 10; /*


To:
    LPC_TIM0->MR0 = 10; /* Set up 10 mS interval 1000 * 10 = 10ms */
    LPC_TIM0->MR1 = 10; /* Set up 10 mS interval */

It's a 10us interval.

Called the function like this:
init_timer(0,90-1); //90 = 10us


This works fine
I also found an gpio.c file that did not work well, modified it, it's now working fine
0 件の賞賛
返信

1,606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Kartman on Fri Apr 29 16:25:57 MST 2011
Sounds like a job for the input capture feature of the timers.
0 件の賞賛
返信