[an error occurred while processing this directive]
|
текст программы написан на ICCAVR ...
Посылаю и принимаю все через Com Port Tolking...
Адаптер RS 232 проверил - 100% рабочий...
текст:
#include //TIMER0 initialize - prescale:1024 заранее благодарен !!!
E-mail:
info@telesys.ru
#include
unsigned char ctr=0;
unsigned char a;
void port_init(void)
{
DDRB = 0xFF;
}
// desired value: 50Hz
// actual value: 50,704Hz (1,4%)
void uart0_init(void)
{
UCSRB = 0x00; //disable while setting baud rate
UCSRA = 0x00;
UCSRC = BIT(URSEL) | 0x06;
UBRRL = 0x17; //set baud rate lo
UBRRH = 0x00; //set baud rate hi
UCSRB = 0x18;
}
//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;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
unsigned char ReceiveByte( void )
{
while (!(UCSRA & (1<
return UDR;
}
}
unsigned char TransmitByte( unsigned char data )
{
while(!(UCSRA&(1<
UDR = data;//data; /* start transmittion */
}
void main(void)
{
init_devices();
while(1)
{
TransmitByte(ReceiveByte());
}
}
если у кого есть возможность(и желание)то напишите ответ в ICQ 127229
Ответы
Перейти к списку ответов
|||
Конференция
|||
Архив
|||
Главная страница
|||
Содержание