1 2 Previous Next 16 Replies Latest reply on Aug 11, 2015 12:25 AM by Sriranjan

    Using an external clock interrupt on timers in edison

    Sriranjan

      Hello,

       

      I want to use an external clock input for the timers in Edison.I am new to edison.I just bought a board. How shall I configure the timers and use an external clock for interrupts.

      // setup timer1 for codec clock division
        TCCR1A = 0x00; // set to CTC mode
        TCCR1B = 0x0f; // set to CTC mode, external clock
        TCCR1C = 0x00; // not used
        TCNT1H = 0x00; // clear the counter
        TCNT1H = 0x00;
        #if SAMPLE_RATE == 88
          OCR1AH = 0x00; // set the counter top
          OCR1AL = 0x3f;
        #elif (SAMPLE_RATE == 44) || (SAMPLE_RATE == 22)
          OCR1AH = 0x00; // set the counter top
          OCR1AL = 0x7f;
        #elif SAMPLE_RATE == 8
          OCR1AH = 0x02; // set the counter top
          OCR1AL = 0xbf;
        #elif SAMPLE_RATE == 2
          OCR1AH = 0x04; // set the counter top
          OCR1AL = 0x7f;
        #endif
        TIMSK1 = 0x02; // turn on compare match interrupt
      
        // turn off all enabled interrupts (delay and wire)
        TIMSK0 = 0x00;
        TWCR = 0x00;
      
        sei(); // turn on interrupts
      

      I want my timer code to do that above thing which is for atmega328. So can some one tell me how to use the timers and how to use external clock signal for it.?Thanks

        1 2 Previous Next