sw uart reset m128 everytime

some days I had a problem and can´t solved it, and try to post here to somebody help me in a thing that I make wrong.

I made a code that get tx/rx from Usart0 then send/receive by a sw uart.

I can send and received correctly by hyperterminal bytes, and can receive bytes from sw uart. The problem is when I try to send byte by sw uart.

To send a byt I need high INT4 25ms then low more 25ms, then send byte, but exactly by put high PE4 the m128 restart. I make several tests and with avr studio debuging don´t restart code, work perfeclty. Proteus simulate perfectly too. GDB too. They don´t show me a bug in code.

But when I run code in board when I put INT4 high, m128 restart. I´m going crazy.

some infos:

  • I use ISR(INT4_vect) to detect coming bytes

  • fuses → lfuse(EF), hfuse(D8 ), efuse(FF)

  • m128 at 12mhz with reset - 10k - vcc

  • I make high and low as follow:

#define line_high() LINE_PORT &=~ _BV(LINE_OUT)
#define line_low()LINE_PORT |= _BV(LINE_OUT)
#define is_line_out_high() bit_is_set(LINE_PORT, LINE_OUT)
#define is_line_high() bit_is_clear(LINE_PIN,LINE_IN)
  • sw_uart_setup:
LINE_DIR |= _BV(LINE_OUT);
line_high();
LINE_DIR &=~ _BV(LINE_IN);
  • sw_uart_init:
  timer0_start(T0_PRESCALER);
  EICRA |= _BV(ISC21)|_BV(ISC20);
  EIFR = _BV(INTF4);
  EIMSK = _BV(INT4);
  • sw_putc:
void sw_putc(unsigned char data)
{
  EIMSK = 0;
  globals.uart_bit_cnt = 10;
  globals.uart_buffer = data;
  TIFR = (0<<TOIE0);
  TIMSK = (1<<TOIE0);
  globals.uart_reload = (256-globals.uart_n_baud); 
  TCNT0=globals.uart_reload+globals.uart_n_baud/16);
  line_low();
}

some infos more please ask to me.

Thanks a lot for any help!

Regards[/code]