Текст проги.
//ICC-AVR application builder : 04.04.2005 22:31:15
// Target : T2313
// Crystal: 7.3728Mhz
#include ‹iot2313v.h›
#include ‹macros.h›
unsigned char hbit=1;
void port_init(void)
{
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x00;
DDRB = 0x00;
PORTD = 0x7F;
DDRD = 0x00;
}
//UART0 initialize
// desired baud rate: 9600
// actual: baud rate:9600 (0,0%)
void uart0_init(void)
{
UCSRB = 0x00; //disable while setting baud rate UCSRB
UBRRH = 0x00; //set baud rate upper
UBRRL = 0x2F; //set baud rate lower
UCSRA = 0x00;
UCSRC = 0x06; //
UCSRB = 0x08; //enable
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
uart0_init();
MCUCR = 0x00;
GIMSK = 0x00;
TIMSK = 0x00;
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main (void)
{
init_devices();
while(1)
{
if (PIND & 0x04)
{
hbit = 0;
}
if (!(PIND & 0x04) & !hbit ) // !
{
putchar('O');
putchar('k');
putchar(0x0D);
hbit = 1;
}
}
}
Подключаю к компу через
MAX232.
Спасибо.