Can't run I2C(TWI) controller on the ATmega88?

Espana the breadboard ATmega88PA 545dccb585d245b49a42024c6dff79e5.JPG,
here is a C program in AVRStudio 5.0 which it is stitched (make slave)
#define F_CPU 12000000UL // 1MHz - default in hardware
#include <avr io.h>
#include <util delay.h>
#include <avr interrupt.h>

#define ME_ADDR 8 //0b00001000 

#define LED_ON 1
#define LED_OFF 2

unsigned char data, flag_new_data=0, status_led=0, stat; ///
unsigned short tek_delay, ddelay=5000;

unsigned char I2C_GetStatus(void) { //read status
unsigned char status; //variable storage
status = TWSR & 0xF8; //mask
return status;
}

void I2C_Init (void) { //initialize I2C as receiver
TWAR=ME_ADDR;// the address for
TWCR=(1<<twea) allowed confirmation |(1<<twen) include a twi module |(1<<twie) interrupt |(0<<twsta) formerit start this type of master |(0<<twsto) to make the stop. |(1<<twint); the interrupt flag. Resetting it means that the state machine will be turned on, and will be again caught } isr(twi_vect) { stat="I2C_GetStatus();" if((stat="=0x80)" || (stat="=0x88))" came the data from the master (0x80 - adopted subsequent bytes 0х88 last byte) data="TWDR;" reads the value of flag_new_data="1;" twcr|="(1<<TWINT);" discharged twcr="(0<<TWSTA)|" (0<<twsto)| (1<<twint)| (1<<twea)| enable ack. The resolution of the response otherwise, to respond to your address to give the ack in all cases when required by Protocol. For example, after the reception of the data. we need to send a nack bit is not set. (1<<twen)| (1<<twie); void set_led(short set_l){ if(set_l="=LED_OFF)" setting pc0 pin low in order to turn off led. portc &="~(1" << portc0); return; high on |="(1" int main(void) ddrc="0x1;" do set_led output(led_on); _delay_ms(2000); set_led(led_off); i2c_init(); module initialization sei(); enable global interrupt while(1){ if(tek_delay < ddelay) tek_delay++; _delay_ms(1); else if(status_led="=0)" tek_delay="0;"status_led="1;" if(flag_new_data="=1){" if(data="=23)" ddelay="300;" }< code></twea)></avr></util></avr>
<br / > The task is to connect the Arduino master - slave ATmega88PA <br> The part that makes the Arduino provereno - works<br> But the slave does not like does not accept interrupts<br> What else can you do to make them work?
August 23rd 19 at 10:58
0 answer

Find more questions by tags Microcontrollers