Atmega168-> ISR( TWI_vect) --> Don't work ¿?

View: New views
1 Messages — Rating Filter:   Alert me  

Atmega168-> ISR( TWI_vect) --> Don't work ¿?

by Jesús Genicio-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi to all: ( sorry for my bad typewriter :))

avr-gcc chus@rivendel:~/avr/arduino-0017$ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../src/configure -v --enable-languages=c,c++
--prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man
--bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib
--enable-shared --with-system-zlib --enable-long-long --enable-nls
--without-included-gettext --disable-checking --disable-libssp
--build=i486-linux-gnu --host=i486-linux-gnu --target=avr
Thread model: single
gcc version 4.3.2 (GCC)

Debian 5.0 ( Linux rivendel 2.6.26-2-686 #1 SMP Sun Jul 26 21:25:33
UTC 2009 i686 GNU/Linux)

This code don't make interrupt ¿?.

#include </home/chus/avr/AVR/librerias/I2C/I2C_Interrups.h>


ISR( TWI_vect)
{
/* uint8_t   twst;
        char buffer[7];
        twst = TW_STATUS & ATmega168_I2C_Prescaler_1_Mask;
       
        switch ( twst)
        {
                case TW_START:
                       
                        break;
        }
*/
  Arduino_Nano_Led_L_Set_On;
}

When i send one I2C_Start, the led don't set on ¿?

Others interrupts, like Timer0 or Timer2, run ok



/*---------------------------------------------------- I2C
Configuration -----------------------------------------------------*/


/* Speed definition:

F_CPU= 16000000UL for Arduino Nano




F_CPU 16000000
        Prescaler

Bus          1 4 16 64
50000 152 38 9,5 2,375
100000 72 18 4,5 1,125
150000 45 11 2 0
200000 32 8 2 0,5
250000 24 6 1,5 0
300000 18 4 1 0
350000 14 3 0 0
400000 12 3 0 0

*/

#define ATmega168_I2C_Prescaler_1 TWSR &= ~_BV( TWPS1) & ~_BV( TWPS0)
#define ATmega168_I2C_Prescaler_4 TWSR |=  _BV( TWPS0)
#define ATmega168_I2C_Prescaler_16 TWSR |=  _BV( TWPS1)
#define ATmega168_I2C_Prescaler_64 TWSR |=  _BV( TWPS1) | _BV( TWPS0)

#define ATmega168_I2C_Prescaler_1_Mask  0xF8 // Se usa esta por defecto
#define ATmega168_I2C_Prescaler_4_Mask  0xF9
#define ATmega168_I2C_Prescaler_16_Mask 0xFA
#define ATmega168_I2C_Prescaler_64_Mask 0xFB

#define ATmega168_I2C_Bit_Rate__50K     ATmega168_I2C_Prescaler_1; TWBR= 152
#define ATmega168_I2C_Bit_Rate__100K    ATmega168_I2C_Prescaler_1; TWBR=  72
#define ATmega168_I2C_Bit_Rate__150K    ATmega168_I2C_Prescaler_1; TWBR=  45
#define ATmega168_I2C_Bit_Rate__200K    ATmega168_I2C_Prescaler_1; TWBR=  32
#define ATmega168_I2C_Bit_Rate__250K ATmega168_I2C_Prescaler_1; TWBR=  24
#define ATmega168_I2C_Bit_Rate__300K ATmega168_I2C_Prescaler_1; TWBR=  18
#define ATmega168_I2C_Bit_Rate__350K ATmega168_I2C_Prescaler_1; TWBR=  14
#define ATmega168_I2C_Bit_Rate__400K ATmega168_I2C_Prescaler_1; TWBR=  12

#define ATmega168_I2C_Set_Power_Reduction_TWI PRR |= _BV( PRTWI);

#define ATmega168_I2C_TWIN_bit 0x80
/*----------------------------------------------------------------------------------------------------------------------------*/

/* Set SDA and SCL to out */

#define ATmega168_I2C_Direction_Port DDRC
#define ATmega168_I2C_Data_Port      PORTC
#define ATmega168_I2C_Pins_Port      PINC

#define ATmega168_I2C_SDA_Pin  4
#define ATmega168_I2C_SCL_Pin  5

#define ATmega168_I2C_Enabled_Port    ATmega168_I2C_Direction_Port |=
_BV( ATmega168_I2C_SDA_Pin) | _BV( ATmega168_I2C_SCL_Pin)
#define ATmega168_I2C_Set_Ack_Bit                             TWCR |= _BV( TWEA)
#define ATmega168_I2C_Enable_Interrupts      TWCR |= _BV( TWIE)
#define ATmega168_I2C_Enable_I2C_System      TWCR |= _BV( TWEN)
/*----------------------------------------------------------------------------------------------------------------------------*/


void ATmega168_I2C_Init()
{
ATmega168_I2C_Bit_Rate__400K;
ATmega168_I2C_Enabled_Port;
ATmega168_I2C_Enable_I2C_System;
ATmega168_I2C_Enable_Interrupts;
}


I compiling with:

#!bin/bash

avr-gcc -g -Os -Wl,-u,vfprintf -lprintf_flt -lm -mmcu=atmega168 -c $1 -o demo.o
avr-gcc -g -Wl,-u,vfprintf -lprintf_flt -lm -mmcu=atmega168 -o demo.elf demo.o
avr-gcc -g -Wl,-u,vfprintf -lprintf_flt -lm -mmcu=atmega168
-Wl,-Map,demo.map -o demo.elf demo.o
avr-objcopy -j .text -j .data -O ihex demo.elf i2c.hex




Regards.


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list