Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Programming Questions / Re: how to calculate clock cycle of an instruction on: April 15, 2014, 10:32:21 am
The Lost Art of Cycle Counting
2  Using Arduino / Programming Questions / Re: interrupt starts at different times depending on upload time of program on: April 07, 2014, 10:59:41 am
why is this in there?

Code:
Serial.begin(9600);
3  Using Arduino / Programming Questions / Re: Effect of switch bounce on external interrupt ? on: March 21, 2014, 01:07:15 pm
Normally, the AVR hardware clears the global interrupt flag (in SREG) before entering an interrupt. This means other interrupts are disabled inside the running handler until the handler finishes and exits.

The RETI instruction is the normal function epilogue for an interrupt handler, and thus re-enables interrupts (just like executing an SEI instruction).

For this reason, normally, interrupt handlers can not be nested.

Search ISR(XXX_vect, ISR_NOBLOCK) for a way around this.

or

http://ucexperiment.wordpress.com/2013/05/20/nested-interrupts/

4  Using Arduino / Programming Questions / Re: Need help with "speed optimization" on: March 16, 2014, 09:44:23 pm
#define intHold 7

volatile int c = 0;
volatile int r = 0;

//Increase tooth count by one
void count() {
  c++;
  if(c == 4)
    //digitalWrite(intHold, HIGH);
    PORTD = B10000000;
  else if(c == 6)
    //digitalWrite(intHold, LOW);
    PORTD = B00000000;
  else if(c == 10)
    //digitalWrite(intHold, HIGH);
    PORTD = B10000000;
  else if(c == 12)
    //digitalWrite(intHold, LOW);
    PORTD = B00000000;
}
                                           
//Reset tooth count
void reSet() {
  c = 0;
  r++;
}

void setup() {
  pinMode(intHold, OUTPUT);          //intHold output to TPIC8101 on pin 6
  digitalWrite(intHold, LOW);
  attachInterrupt(0, count, RISING); //24 tooth interrupt on pin 2 calls to function count below
  attachInterrupt(1, reSet, RISING); //1 tooth "reset" interrupt on pin3 calls to function reSet below
  Serial.begin(9600);
  Serial.println("Setup");           //verify setup completed
}

void loop() {                        //Verify resets are working
  if(r > 1) {
    Serial.println("reset");
    r = 0;
  }     
}
5  Using Arduino / Programming Questions / Re: Maths precision for Arduino? on: January 29, 2014, 05:18:43 pm
https://sites.google.com/site/wayneholder/self-driving-rc-car/getting-the-most-from-gps
6  Using Arduino / Programming Questions / Re: $50 bounty: report pitch and roll minus any acceleration effects on: January 28, 2014, 03:56:17 pm
No takers? C'mon guys! Why is this so hardddddd

Two words: kalman filter
7  Using Arduino / Programming Questions / Re: Measuring execution time of functions without Serial.print on: January 24, 2014, 12:43:35 pm
Does this code profiler help?
8  Using Arduino / Programming Questions / Re: Can 'blocked' code miss an interrupt? on: January 15, 2014, 02:26:59 pm
Buttom bounce issue?
9  Using Arduino / Programming Questions / Re: Programatically accessing stack and heap pointers? on: October 29, 2013, 11:57:53 pm
http://playground.arduino.cc/Code/AvailableMemory
10  Using Arduino / Programming Questions / Re: attachInterrupt() calls wrong function upon interrupt on Arduino Mega2650 on: September 23, 2013, 06:59:08 pm
What board are you compiling for? Because when I compile your code I get the following IVT:

Code:
00000000 <__vectors>:
   0: 71 c0        rjmp .+226    ; 0xe4 <__ctors_end>
   2: 00 00        nop
   4: 57 c1        rjmp .+686    ; 0x2b4 <__vector_1>
   6: 00 00        nop
   8: 86 c1        rjmp .+780    ; 0x316 <__vector_2>
   a: 00 00        nop
   c: b5 c1        rjmp .+874    ; 0x378 <__vector_3>
   e: 00 00        nop
  10: e4 c1        rjmp .+968    ; 0x3da <__vector_4>
  12: 00 00        nop
  14: 13 c2        rjmp .+1062    ; 0x43c <__vector_5>
  16: 00 00        nop
  18: 42 c2        rjmp .+1156    ; 0x49e <__vector_6>
  1a: 00 00        nop
  1c: 71 c2        rjmp .+1250    ; 0x500 <__vector_7>
  1e: 00 00        nop
  20: a0 c2        rjmp .+1344    ; 0x562 <__vector_8>
  22: 00 00        nop
  24: 7f c0        rjmp .+254    ; 0x124 <__bad_interrupt>
  ...
11  Using Arduino / Programming Questions / Re: Display floating point temperature on 7-segment display on: September 20, 2013, 04:32:24 pm
Multiply the float by 100 and convert it to an integer.

Code:
int intTemp = floatTemp * 100;

This will turn 12.3456 into 1234.
Now you can display the digits onto the 7 segment display and simply enable the dot before the last two digits.

How about if the temperature is 100.1?
12  Using Arduino / Programming Questions / Re: Arduino assembler programming on: August 15, 2013, 09:57:34 am
Inline Assembly is a good method to get your feet wet. However it has somewhat odd and confusing syntax.

Mixing C and assembly in AVR Studio is another method.

Check out the book, "Programming Microcontrollers using Assembly Language" for an excellent primer.

Goodluck...
13  Using Arduino / Programming Questions / Re: All about timers - how to handle sw interrupts? on: July 20, 2013, 11:06:58 am
Timers generate hardware interrupts - a software interrupt is something different.

Per Datasheet:

"The External Interrupts are triggered by the INT0 and INT1 pins or any of the PCINT23..0 pins. Observe that, if enabled, the interrupts will trigger even if the INT0 and INT1 or PCINT23..0 pins are configured as outputs. This feature provides a way of generating a software interrupt."
14  Using Arduino / Programming Questions / Re: Incorrectly calculating elapsed time between interrupts. on: July 12, 2013, 03:34:07 pm
Just curious, have you tried to install the interrupt without using Arduino's attachInterrupt() function?

Also, there is a known issue with calling micros() with IRQs disabled and the potential for timer0 rollover, however, I don't believe this to be your issue.
15  Topics / Science and Measurement / Re: Oscilliscope for beginners on: July 11, 2013, 07:56:23 am
Understanding Signals Tutorial at: http://www.parallax.com/go/propscope
Pages: [1] 2 3 ... 6