예제 #1
0
int main(void) {
    USE_AS_OUTPUT(LED);
    onewire__bus__init();
    onewire__bus__set(1);
    _delay_ms(1);

    timer2__compare_a__interrupt__enable();
    timer2__overflow__interrupt__enable();
    timer2__conf__set(TIMER2_CONF_PRESCALER_64|TIMER2_CONF_WGM_NORMAL);

    sei();
    for(;;) {        
        onewire__bus__set(0);
        timer2__value__set(256 - 138);                      // 118
        timer2__compare_a__value__set(256 - 138 + 120);     // 238
        // will count 238-118 = 120 cycles until compare event (480uS), and 18 more cycles (72uS) until flag is set
        
        _delay_ms(1);
    }
}
예제 #2
0
void schedule(void) {
    timer2__value__set(0);
    timer2__compare_a__value__set(240); // 960uS
    timer2__conf__set(TIMER2_CONF_PRESCALER_64|TIMER2_CONF_WGM_NORMAL);
}