Teensy USB Interrupts | Microcontrollers | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
Teensy USB Interrupts
No permission to create posts
April 13, 2017
2:59 am
Avatar
chulian1
New Member
Members
Forum Posts: 1
Member Since:
April 13, 2017
sp_UserOfflineSmall Offline

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);
    }
}

April 23, 2017
10:32 am
Avatar
Vinod

MathWorks
Members
Forum Posts: 200
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

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:
13 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

harriettlf60, ShaToow, Aleftinfenny, DiaBentee, hugo11dom@gmail.com, Pisaruk530

Administrators: Hans: 387, lee: 457