Go Down

Topic: PinChangeInt library- To attach interrupts to multiple Arduino (Uno/Mega) pins (Read 21 times) previous topic - next topic

DuaneB

Big change, from 108 instructions to 54 - cut the time in half !

Code: [Select]

     358: e5 2e        mov r14, r21
     35a: ff 24        eor r15, r15
     35c: 1c c0        rjmp .+56      ; 0x396 <_ZN9PCintPort5PCintEv+0x78>
     35e: 8b 81        ldd r24, Y+3 ; 0x03
     360: 28 2f        mov r18, r24
     362: 30 e0        ldi r19, 0x00 ; 0
     364: c7 01        movw r24, r14
     366: 82 23        and r24, r18
     368: 93 23        and r25, r19
     36a: 89 2b        or r24, r25
     36c: 89 f0        breq .+34      ; 0x390 <_ZN9PCintPort5PCintEv+0x72>
  #ifndef NO_PIN_STATE
  PCintPort::pinState=PCintPort::curr & p->mask ? HIGH : LOW;
     36e: 80 91 44 01 lds r24, 0x0144
     372: 40 e0        ldi r20, 0x00 ; 0
     374: 90 e0        ldi r25, 0x00 ; 0
     376: 82 23        and r24, r18
     378: 93 23        and r25, r19
     37a: 89 2b        or r24, r25
     37c: 09 f0        breq .+2      ; 0x380 <_ZN9PCintPort5PCintEv+0x62>
     37e: 41 e0        ldi r20, 0x01 ; 1
     380: 40 93 46 01 sts 0x0146, r20
  #endif
  #ifndef NO_PIN_NUMBER
  PCintPort::arduinoPin=p->arduinoPin;
     384: 8c 81        ldd r24, Y+4 ; 0x04
     386: 80 93 45 01 sts 0x0145, r24
  #endif
  #ifdef PINMODE
  PCintPort::pinmode=p->mode;
  #endif
  p->PCintFunc();
     38a: e8 81        ld r30, Y
     38c: f9 81        ldd r31, Y+1 ; 0x01
     38e: 09 95        icall
      }
      p = p->next;


Great work Rob and greynomad

Duane B

rcarduino.blogspot.com

DuaneB

The update in action reading RC Signals -



The red line is before, the green line is after. They both represent the maximum variation between two consecutive RC Pulses in 10 seconds periods. There are three channels, when one channel goes high, the adjacent channel goes low meaning we will often need to service two interrupts in one call to the ISR, the improved efficiency has a visible effect in the graph.

Full explanation of the graph towards the end of this -
http://rcarduino.blogspot.com/2012/11/how-to-read-rc-channels-rcarduinofastlib.html

Duane B

rcarduino.blogspot.com

robtillaart

what are the average numbers of blue, red and green? (I do not fully understand the test As I did not dived into it yet :)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

DuaneB

Hi,
   The test is very application specific and not a good way to measure pinchangeint performance, however it does illustrate that there is a improvement.

A quick look at the assembly suggests that the instructions have been reduced from 104 to 52 - a saving of 50%.

My application is reading RC Signals, when one pin toggles, the adjacent pin also toggles, this means that the pin change int library will be servicing two pins each time it is called so the saving is very significant in this particular application.

Duane B

rcarduino.blogspot.com

Graynomad

Quote
Great work Rob and greynomad

Much as I'd love to take the credit you probably meant GreyGnome :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Go Up