Требуется программист в Зеленограде
- обработка данных с датчиков; ColdFire; 40 тыс. e-mail:jobsmp@pochta.ru |
Почему??? void port_init(void) //TIMER1 initialize - prescale:8 #pragma interrupt_handler uart0_rx_isr:12//постоянно попадаю сюда... //////////////////////////////////////////////// if(Rdata == 0x54)//"T"//test void init_devices(void) MCUCR = 0x00;
#include
#include
unsigned short int countInterrupt;
unsigned char Rdata;
{
DDRC = 0xFF;
DDRD = 0x70;
DDRB = 0xFF;
}
// WGM: 0) Normal, TOP=0xFFFF
// desired value: 49uSec
// actual value: 47,743uSec (2,6%)
void timer1_init(void)
{
TCCR1B = 0x00;
TCNT1H = 0xFF;
TCNT1L = 0xEA;
OCR1AH = 0x00;
OCR1AL = 0x16;
OCR1BH = 0x00;
OCR1BL = 0x16;
ICR1H = 0x00;
ICR1L = 0x16;
TCCR1A = 0x00;
TCCR1B = 0x02;
}
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 = 0x98;
}
void uart0_rx_isr(void)
{
Rdata=UDR;
{
TransmitByte(Rdata);
Test();
}
////////////////////////////////////////////////
}
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
timer1_init();
uart0_init();
GICR = 0x00;
TIMSK = 0x04; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//////////////////////////////////////////////////
/// Transmite Data ///
//////////////////////////////////////////////////
void TransmitByte( unsigned char data ) ///
{ ///
while( !(UCSRA & (1<
UDR = data;//data; /* start transmittion *////
} ///
//////////////////////////////////////////////////
/**********************************************///
//////////////////////////////////////////////////
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
//////////////////////////////////////////////////
/// Delay(Frequency) ///
//////////////////////////////////////////////////
void Delay(unsigned short int F) ///
{ ///
countInterrupt = 20200/F; ///
while(countInterrupt > 0) ///
{ ///
while (!(TIFR & 0x04)); ///
TCNT1H = 0xFF; ///
TCNT1L = 0xEA; ///
TIFR = 0x04; ///
countInterrupt --; ///
} ///
} ///
//////////////////////////////////////////////////
/************************************************/
//////////////////////////////////////////////////
/////////////////////////////////////////////
/// Test ///
/////////////////////////////////////////////
void Test(void) ///
{ ///
int z; ///
z=6; ///
while(z!=0) ///
{ /// ///
PORTD ^= BIT(5); ///
Delay(1); ///
z--; ///
} ///
} ///
/////////////////////////////////////////////
/*******************************************/
/////////////////////////////////////////////
void main(void)
{
init_devices();
while(1)
{
}
}
Ответы