//TEST Transmit Unit //Includes #include #include<.\txrx.c> //definitions #define begin { #define end } #define data_length 4 #define tx_id 3 #define threshold 1000 //declarations char data[data_length]; unsigned char packet_count; unsigned int time; //********************************************************** //timer 0 compare ISR interrupt [TIM0_COMP] void timer0_compare(void) begin if(time<=threshold) time++; end //********************************************************** void generate_data(char count) begin data[0] = count; data[1] = 26; data[2] = 122; data[3] = 75; data[4] = 52; end //********************************************************** //initialization void init() begin //Used for LED array, output DDRC = 0xff; PORTC=0xff; //starting off //PORTD used for TX. //d7 led, d1 TX, d0,d2..6 unused DDRD = 0xff; PORTD.7=0; //turn d7 led on as power-on led //set up timer 0 TIMSK=2; //turn on timer 0 cmp match ISR OCR0 = 250; //set the compare re to 250 time ticks //prescalar to 64 and turn on clear-on-match TCCR0=0b00001011; txrx_init(1,0,249,1);//TX only - 4000 baud - led on //initialize variables time=0; packet_count=0; generate_data(packet_count); #asm ("sei"); end //********************************************************** void main() begin init(); while(1) begin if(time==threshold) begin generate_data(packet_count); tx_me(data, data_length, tx_id); time=0; PORTD.7 = 1; packet_count++; end end //while end //main