Teensy USB Interrupts | Microcontrollers | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Teensy USB Interrupts
Avatar
chulian1
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
1
April 13, 2017 - 2:59 am
sp_Permalink sp_Print

I'm trying to learn about interrupts using one of the Teensy USB boards. It's got an AVR AT90USB1286 chip on it. I'm using the code below, and I'm expecting my ISR block to get called and periodically flash the LED on pin 6. But nothing is happening. Can anyone see what I'm doing wrong?

Code:
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include <avr/interrupt.h>

#define PIN_ON(n) (PORTD |= (1<<(n)))
#define PIN_OFF(n) (PORTD &= ~(1<<(n)))

#define LED_CONFIG  (DDRD |= (1<<6))
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))

#define OVERFLOW_INTERRUPT_ENABLE (TIMSK0 |= (1<<TOIE0))


volatile unsigned int overflow_count = 0; //Count of overflows

ISR(TIMER0_OVF_vect) {
  cli(); //Disable Global Interupt
  if (overflow_count < 0xFFFF) {
    overflow_count++;
  }
  else {
    PIN_ON(6);
    _delay_ms(500);
    PIN_OFF(6);
    overflow_count = 0;
  }
  sei(); //enable global interupt

}
int main(void)
{

    // set for 16 MHz clock, and make sure the LED is off
    CPU_PRESCALE(0);
    LED_CONFIG;
    OVERFLOW_INTERRUPT_ENABLE;
    sei(); //enable global interupts


    while (1) {
      _delay_ms(1000);
      //analogWrite(6, 10);
    }
}

Avatar
Vinod

Forum Posts: 154
sp_UserOfflineSmall Offline
2
April 23, 2017 - 10:32 am
sp_Permalink sp_Print

I'm not sure how ThingSpeak fits in here. Perhaps this post is more relevantĀ on the Arduino forums?

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
12 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 250

Vinod: 154

cstapels: 83

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

webone

KMVp

aamir786

sugengprayogi

vickysam@gmail.com

farmerkjs

Forum Stats:

Groups: 4

Forums: 17

Topics: 1289

Posts: 4481

 

Member Stats:

Guest Posters: 1

Members: 5652

Moderators: 0

Admins: 2

Administrators: Hans, lee