update ldscript
[protos/xbee-avr.git] / int_show.c
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: int_show.c,v 1.6.10.3 2008-05-09 08:23:52 zer0 Exp $
19  *
20  */
21
22 #include <avr/io.h>
23 #include <aversive.h>
24 #include <diagnostic.h>
25
26
27 #ifdef INTERRUPT_SHOW_PORT
28
29 /** this loop is to be used as main program if you have interrupts
30   * running and want to see how much time is consumed by the
31   * interrupts.  you must then observe the test pin with an
32   * oscilloscope, or eventually a multimeter.  as long as there are no
33   * interrupts, the test port will toggle at 50% rate. when an
34   * interrupt occurs, the port stops to toggle, and remain low. the
35   * space before the next impulsion is the int time (always one toggle
36   * between ints!)  if you look whith a multimeter, the processor free
37   * time is proportinnal to the observed voltage.  0V corresponds to
38   * an always busy processor, while if you read Vcc/2 the processor is
39   * almost always free. */
40 void show_int_loop(void)
41 {
42         sbi(DDR(INTERRUPT_SHOW_PORT), INTERRUPT_SHOW_BIT);
43
44         while(1) {
45                 cbi(INTERRUPT_SHOW_PORT, INTERRUPT_SHOW_BIT); // port to 0
46                 
47                 sei();
48                 nop(); // ints can only arrive there (on low level of probe pin)
49                 cli();
50                 
51                 sbi(INTERRUPT_SHOW_PORT, INTERRUPT_SHOW_BIT); // port to 1
52                 
53                 nop(); // is there to equalize the duty cycle
54         }
55 }
56 #endif