diff -r 9857c18c5e64 -r 018d4d63ad3b blackbox/main.c --- a/blackbox/main.c Wed Dec 07 15:56:05 2011 +0100 +++ b/blackbox/main.c Wed Dec 07 16:50:51 2011 +0100 @@ -30,6 +30,10 @@ #define MAX_SLOTS 6 +volatile uint16_t sysclk_ms_low = 0; +volatile uint16_t sysclk_ms_high = 0; +volatile uint8_t sysclk_packettimer = 0; + volatile uint8_t speedlimit[MAX_SLOTS]; volatile uint8_t fuel[MAX_SLOTS]; volatile uint8_t jumpstart_time[MAX_SLOTS]; @@ -134,8 +138,7 @@ void jumpstart(uint8_t controller) { if (jumpstart_time[controller] == 0) { - jumpstart_time[controller] = 1; - // todo: later the timestamp should written instead of just "1" + jumpstart_time[controller] = sysclk_ms_low; RS232_putc('~'); RS232_putc('0'-controller); RS232_putc('\n'); @@ -238,14 +241,21 @@ } ISR ( TIMER1_COMPA_vect ) { + //PORTC ^= _BV(PC0); // DEBUG OUTPUT SYSTEM CLOCK + // trigger packet transfer: - transmit_len = transmit_len_next; + if (sysclk_packettimer == 14) { // 15*500 = 7500 NS + transmit_len = transmit_len_next; + sysclk_packettimer = 0; + } else sysclk_packettimer++; // here is some more time to do something else... // reset both car counters to overflow - car0_old = TIMER1_7500NS; - car1_old = TIMER1_7500NS; + car0_old = TIMER1_500NS; + car1_old = TIMER1_500NS; + sysclk_ms_low++; // increment 500ns timer + if (sysclk_ms_low == 0) sysclk_ms_high++; // increment upper 16bits } ISR ( TIMER2_COMP_vect ) { @@ -360,7 +370,7 @@ void reset_vars(void) { uint8_t i; for (i=0; i