Подскажите что может быть, в протеусе работает, в контроллере нет, вернее на вывод в комп все пашет, кварц стоит на 4 Мгц, а вот от команд с ПК, типа цифры от 1 до 8, не работает.
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/iotn2313.h>
#include <util/delay.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#define BAUD (4000000/16/9600 - 1)
#define USART_RXC_vect USART_RX_vect
void sleep(void);
volatile unsigned char rxbuff;
volatile unsigned int rx_int = 1;
SIGNAL(SIG_USART0_RECV)
{
if (bit_is_clear(UCSRA, FE))
{
rxbuff=UDR;
rx_int=1;
}
}
void sleep(void)
{
int i;
for (i=0; i<=10; i++)
_delay_loop_2(30000);
}
void RestartPin(int PinNumber)
{
sleep();
switch (PinNumber)
{
case 1:
PORTB=PORTB | (1<<PB0);
sleep();
PORTB=PORTB & (0<<PB0);
sendString(" TC1 Ok\0");
break;
case 2:
PORTB=PORTB | (1<<PB1);
sleep();
PORTB=PORTB & (0<<PB1);
sendString(" TC2 Ok\0");
break;
case 3:
PORTB=PORTB | (1<<PB2);
sleep();
PORTB=PORTB & (0<<PB2);
sendString(" TC3 Ok\0");
break;
case 4:
PORTB=PORTB | (1<<PB3);
sleep();
PORTB=PORTB & (0<<PB3);
sendString(" TC4 Ok\0");
break;
case 5:
PORTB=PORTB | (1<<PB4);
sleep();
PORTB=PORTB & (0<<PB4);
sendString(" TC5 Ok\0");
break;
case 6:
PORTB=PORTB | (1<<PB5);
sleep();
PORTB=PORTB & (0<<PB5);
sendString(" TC6 Ok\0");
break;
case 7:
PORTB=PORTB | (1<<PB6);
sleep();
PORTB=PORTB & (0<<PB6);
sendString(" TC7 Ok\0");
break;
case 8:
PORTB=PORTB | (1<<PB7);
sleep();
PORTB=PORTB & (0<<PB7);
sendString(" TC8 Ok\0");
break;
}
}
int main(void)
{
// DDRA = 0x00; //1 - out, 0 - in
DDRB = 0xFF;
USARTInit();
sei();
sleep();
sendString("Welcome to Remote Reset\0");
for (;;)
{
if (rx_int==1)
{
if (rxbuff == '1') RestartPin(1);
if (rxbuff == '2') RestartPin(2);
if (rxbuff == '3') RestartPin(3);
if (rxbuff == '4') RestartPin(4);
if (rxbuff == '5') RestartPin(5);
if (rxbuff == '6') RestartPin(6);
if (rxbuff == '7') RestartPin(7);
if (rxbuff == '8') RestartPin(8);
rx_int = 0;
}
}
return 0;
}
void USARTInit()
{
UBRRL = BAUD;
UCSRB = (1<<RXEN)|(1<<TXEN)|(1<<RXCIE)|(0<<UDRIE);
//UCSRC = (1<<UCSZ1)|(1<<UCSZ0);
}
void sendChar(unsigned char data)
{
while (!(UCSRA &(1<<UDRE))) ;
UDR = data;
}
void sendString(unsigned char s[])
{
int i=0;
while (i<64)
{
if (s[i]=='\0') break;
sendChar(s[i++]);
}
}