avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] interrupt in AVR-libc support ATmega32U4 ?


From: Senthil Kumar Selvaraj
Subject: Re: [avr-gcc-list] interrupt in AVR-libc support ATmega32U4 ?
Date: Fri, 22 Apr 2016 15:23:08 +0530
User-agent: mu4e 0.9.17; emacs 24.5.1

Hi,

  ATmega32u4 does have INT0_vect - the disassembly for your program,
  compiled with 

  $ avr-gcc led.c -mmcu=atmega32u4 -DF_CPU=1800000 -Os
  $ avr-objdump -S a.out

a.out:     file format elf32-avr


Disassembly of section .text:

00000000 <__vectors>:
   0:   0c 94 56 00     jmp     0xac    ; 0xac <__ctors_end>
   4:   0c 94 62 00     jmp     0xc4    ; 0xc4 <__vector_1>
   8:   0c 94 60 00     jmp     0xc0    ; 0xc0 <__bad_interrupt>
</snip>

does show that your handler is correctly hooked up in the vector
table. The specific section in the manual you are referring to hasn't
been updated/auto-generated in ages - I'll see if that can somehow be
fixed.

That apart, I guess you'd want to place the code in main within the
while(1) - with the Arduino code,  digitalWrite(0,HIGH) runs in a loop,
whereas in the C code you pasted, PORTB=0xff runs only once. Perhaps that
explains why the LED doesn't turn on?

Regards
Senthil

辻野 太郎 writes:

> 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
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/avr-gcc-list




reply via email to

[Prev in Thread] Current Thread [Next in Thread]