I try to run a basic program LED_INTv2.c about interrupt.

Connection:
PB0 <---> LED <---> GND,
PD0(INT0) <---> Switch (on: connect)<---> GND

normal : LED on --- switch on --- PD0(INT0)=Low (GND) ---> LED off ---> Switch 
off 
----> PD0(INT0)=High ---> return to main routine ---> LED on 

However, after switch on and off, program does not return to main routine, that 
is, LED off ,
PD0(INT0) remains Low level.

In Sec 23.17 Table of the manual "avr-libc 2.0.0 Mon Feb 8 2016 23:59:10"
there is no ATmega32U4 in the list of devices for which INT0_vect is applicable.
Before I can perform a program of same content using ATtiny261.
ATtiny261 is in the list.

My Harware:
Teensy 2.0 (ATmega32U4)
My Software:
aruduino + Teensyduino.(Windows8.1)

What's problem ?

Is <avr/interrupt.h> applicable for Teensy2.0(ATmega32U4) ?

Can I use only Arduino library for interrupt using Teensy2.0 ?

I can perform a program of same content using Arduino library (LED_INTv4.c). 

%%%%% LED_INTv2.c %%%%%%%%%%%%%%%
#include <avr/io.h>
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
#define CPU_16MHz 0x00
#include <util/delay.h>
#include <avr/interrupt.h>

ISR(INT0_vect){
PORTB=0x00;
reti();
}
int main( void ){
CPU_PRESCALE(CPU_16MHz);
DDRB=0xff;
DDRD=0x0;
PORTB=0xff;
PORTD=0xff;
cli();

SREG=0b10000000;
EICRA=0b00000000; // Interrupt condition : Low Level
EIMSK=0b00000001; // Enable External Interrupt INT0
sei();
while(1);

}


%%%%   LED_INTv4.c  %%%%
void setup() {
pinMode(0,OUTPUT);
pinMode(5,INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(5),turnoff,LOW);
}

void loop() {
  digitalWrite(0,HIGH);
}

void turnoff() {
  digitalWrite(0,LOW);
}
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to