Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / Programming Questions / Re: Atmega8 V-Usb TIMSK0 compile error on: Today at 10:55:22 am
Code probably wasn't designed to run on an ATmega8. An ATmega8 has only one Timer/Counter Interrupt Mask Register (defined as TIMSK not TIMSK0).  A UNO uses an ATmega328 which has 3 interrupt mask registers (TIMSK0, TIMSK2 and TIMSK2). 
2  Using Arduino / Programming Questions / Re: Nokia 5110 display without any libraries on: August 10, 2014, 10:26:48 am
The display is a simple 84x48 pixel array. The PCD8544 controller allows basic functions like turning on/off pixels. Neither the display nor controller contain built-in “character sets”. You need to build your own character set and embed them into your code for each size you desire. Study the code more closely.
3  Using Arduino / Programming Questions / Re: Timer 2 - Clear counter without adding delay to the count on: August 10, 2014, 10:00:38 am
This is a good example of something Ive been previously told it wouldn't be possible to achieve - Cascading timers

As it stands it is very well possible and may significantly reduce the software overhead:,d.d2k

AVR133, cascaded timers implemented on the arduino:
4  Using Arduino / Project Guidance / Re: GPS Laptimer on: July 27, 2014, 06:12:44 pm
IR lap timer

GPS lap timer
5  Using Arduino / Programming Questions / [solved] AVR133 long delay using cascaded timers on: July 22, 2014, 03:40:38 pm
I’m trying to create a long delay by cascading timers via the procedure outlined in Atmel Application Note AVR133. I’ve set timer #1 up to toggle the OCR1A (D9) pin and wired that to the T0 pin (D4) which clocks timer #0. Then I put the arduino to sleep and wait for the timer #0 interrupt to wake it. Or at least that’s what I’m trying to do. The values I’m using should toggle the pin 13 LED at a 1 minute frequency. A much longer delay is easily possible, but I can’t get it t work.

// AVR 133: Atmel Application Note Long Delay Generation
// T = 2/Fs x T1P x OCR1A x (256 - TCNT0)
// T = 2/16000000x256x7500x(256-6)
// T = 60 or 1 minute
// connect arduino D9 to D4:
//  T0 = PD4 (Arduino D4 as input)
//  OC1A = PB1 (Arduino D9 as output)
#include <avr/sleep.h>
#include <avr/power.h>

void setup() {
  //set pins
  DDRB |= (1<<PINB1) | (1<<PINB5); //set arduino D9 and D13 as outputs
  PORTB &= ~(1<<PINB1);            //set D9 low
  PORTD &= ~(1<<PIND4);            //set D4 low

  //timer #1 toggles OCR1A on TCNT1=0 in turn toggling T0
  TCCR1A = (1<<COM1A0); //TCCR1A toggle OC1A on compare match
  TCCR1B = 0;
  TCCR1C = 0;
  OCR1A = 7500;       //output compare register on division ratio of 7500
  TIMSK1 = 0;

  //timer #0 fires interrupt when TCNT0=0 waking arduino
  TCCR0A = 0;
  TCCR0B = 0;
  TIMSK0 = (1<<TOIE0);  //enable timer0 interrupt

void loop() {
  //toggle led
  PORTB ^= (1<<PINB5); //toggle led pin

  //reset timers
  TCNT0 = 6;
  TCCR0B = (1<<CS00) | (1<<CS01) | (1<<CS02); //external source (t0) rising edge
  TCNT1 = 0UL;
  TCCR1B = (1<<WGM12) | (1<<CS12); //CTC mode 4 and 256 prescaler

  //go to sleep here, wake on interrupt
  //stop timers
  TCCR1B = 0;
  TCCR0B = 0;

edit: above code now works.
6  Using Arduino / Programming Questions / Re: How to trigger operation at every hundredth millisecond using ADA Ultimate GPS on: June 12, 2014, 12:50:26 pm
Set your GPS up to send at 10Hz and only one NMEA string, then use code something like this to save after you receive each NMEA sentence.

void loop() {
  char c;

  if (Serial.available()) {
    c =;

    if (c == '\n') {
      //end of gps string received, save sensor data now…
7  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
8  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?

9  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.


10  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() {
  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;

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.println("Setup");           //verify setup completed

void loop() {                        //Verify resets are working
  if(r > 1) {
    r = 0;
11  Using Arduino / Programming Questions / Re: Maths precision for Arduino? on: January 29, 2014, 05:18:43 pm
12  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
13  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?
14  Using Arduino / Programming Questions / Re: Can 'blocked' code miss an interrupt? on: January 15, 2014, 02:26:59 pm
Buttom bounce issue?
15  Using Arduino / Programming Questions / Re: Programatically accessing stack and heap pointers? on: October 29, 2013, 11:57:53 pm
Pages: [1] 2 3 ... 7