- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
sei();
}
if( xp_buff_ready > 0 && pc_rec_en == 0 )
{
for( i=0; xp_buff_ready!=i; i++ )
rs232_transmit(xp_response[i]);
clear_buff(1);
xp_buff_ready = 0;
xp_rec_en = 0;
my_window = 0;
}
if( ack == 1 )
{
rs232_transmit('A');
rs232_transmit('C');
rs232_transmit('K');
rs232_transmit(' ');
rs232_transmit('E');
rs232_transmit('r');
rs232_transmit('r');
rs232_transmit('o');
rs232_transmit('r');
ack = 0;
my_window = 0;
xp_rec_en = 0;
}
};
return 0;
}
void clear_buff(unsigned char buff)
{
if( buff == 0 )
for( i=0; i<18; i++ )
pc_command[i] = 0;
if( buff == 1 )
for( i=0; i<16; i++ )
xp_response[i] = 0;
return;
}
void avr_init(void)
{
// 62500 9bit 1 stop no parity
UCSR0A=0x00;
UCSR0B=0x9C;
UCSR0C=0x86;
UBRR0H=0x00;
UBRR0L=0x0F;
// 56000 8bit 1 stop no parity
UCSR1A=0x00;
UCSR1B=0x98;
UCSR1C=0x06;
UBRR1H=0x00;
UBRR1L=0x11;
DDRC = 0b00000011;
PORTC= 0b00000000;
DDRD = 0b00000001;
PORTD= 0b00000000;
DDRG = 0b00011011; //определить все ножки порта G (PG3 - DE status, PG4 - DE counter)
PORTG = 0b11100100; //включить подтяжку резисторов
DDRD = 0b11111000; //PD0, PD1 - SCL-SDA, PD2 -RxD1, PD3 - TxD1 PD4 - STAT/COUN, PD5 - RE STAT, PD6 - RE Coun, PD7 - testLD
PORTD = 0b01101111; //подключить внутренние резисторы на входах, a выходы установить в "0"
PORTG &=~_BV(PG4); //disable DE RS485
PORTD &=~_BV(PD5); //enable RE RS485
return;
}
guest 19.04.2010 15:36 # −2.8
guest 19.04.2010 15:37 # −0.8