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

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

[avr-gcc-list] TWI interrupt problem


From: Andreas Trenkwalder
Subject: [avr-gcc-list] TWI interrupt problem
Date: Wed, 26 Mar 2003 02:39:56 +0100

Hi!
I'm experementing with the TWI interface of the mega128. I wrote some
simple routines to test the interface without interrups (read and write)
and all seemd to be working pretty fine.
But testing interrupt support I had no luck. You can find a piece of my
code at the end of this message.
This code should set up the mega128's twi hardware and enable interrupt
support. The leds attached to PORTB should change when the interrupt is
raised, but there is no change at all. 
Am I missing something?

Any help would be appreciated.
Andreas


--
void i2c_init(void)
{
  cbi(TWSR, TWPS0);
  cbi(TWSR, TWPS1);
  TWBR = F_CPU/(2 * 100000) - 8;
  // enable ACK, twi interrupt, and twi hardware 
  TWCR = _BV(TWEA) | _BV(TWEN)| _BV(TWIE);
  sei();
}

inline void i2c_start(void)
{
  TWCR = _BV(TWINT)|_BV(TWSTA)|_BV(TWEN);
}

//TWI interrupt service routine
SIGNAL(SIG_2WIRE_SERIAL)
{
  PORTB = 0xF0; 
  TWCR = _BV(TWINT);
}

int main (void)
{
  DDRB = 0xFF;
  PORTB = 0x00;
  i2c_init();
  i2c_start();
  return 0;
}




reply via email to

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