Ejemplo n.º 1
0
/* Start heartbeat timer */
void start_heartbeat(void) {
    TC_OC(TC_HEARTBEAT);
    SET_OC_ACTION(TC_HEARTBEAT,OC_OFF);
    
    TC(TC_HEARTBEAT) = TCNT + HEARTBEAT;    // Preset OC channel
    TC_INT_ENABLE(TC_HEARTBEAT);            // Enable timer channel interrupt
}
Ejemplo n.º 2
0
/* Initialize stepper motor control */
void stepper_init(void) {
    
    // Set initial delay time and step type
    stepper_delay = STEPPER_DELAY_INIT;
    stepper_step_type = STEPPER_STEP_INIT;
    
    // Enable timer module if not already enabled
    if(!(TSCR1 & TSCR1_TEN_MASK)) EnableTimer;
    
    TC_OC(TC_STEPPER);  // Channel set to output compare
    SET_OC_ACTION(TC_STEPPER,OC_OFF);   // Do not change output line after output compare triggered, this is controlled manually
    
    TC(TC_STEPPER) = TCNT + TIMER_DELTA(stepper_delay); // Preset OC channel
    TC_INT_ENABLE(TC_STEPPER);  // Enable timer channel interrupts
    
    SET_BITS(STEPPER_PORT_DDR,STEPPER_COIL_BITS);   // Set stepper coil lines as outputs
    SET_BITS(STEPPER_LIMIT_INPUT_EN,STEPPER_LIMIT_INPUT_EN_MASK);   // Set limit switch ports as inputs
}