mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-15 04:01:04 +00:00
timer
This commit is contained in:
@@ -119,7 +119,8 @@ void setup()
|
|||||||
|
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
|
|
||||||
obd2_RTT_init();
|
obd2_TC_init();
|
||||||
|
|
||||||
statemachine_register_state(&init_state, STATE_INIT);
|
statemachine_register_state(&init_state, STATE_INIT);
|
||||||
statemachine_register_state(&main_state, STATE_CAR_INFO);
|
statemachine_register_state(&main_state, STATE_CAR_INFO);
|
||||||
statemachine_init();
|
statemachine_init();
|
||||||
|
|||||||
@@ -46,8 +46,12 @@ void obd2_RTT_set_period(__UINT32_TYPE__ period)
|
|||||||
|
|
||||||
void obd2_TC_init()
|
void obd2_TC_init()
|
||||||
{
|
{
|
||||||
/* enable the timer/counter 0 */
|
/* disable write protection */
|
||||||
TC0->TC_CHANNEL[0].TC_CCR |= TC_CCR_CLKEN;
|
pmc_set_writeprotect(false);
|
||||||
|
// /* set clock source to main clock */
|
||||||
|
// pmc_mck_set_source(PMC_MCKR_CSS_MAIN_CLK);
|
||||||
|
/* set the clock to MCK/2, enable the timer/counter 0, enable RC compare trigger and capture mode */
|
||||||
|
TC0->TC_CHANNEL[0].TC_CCR |= TC_CMR_TCCLKS_TIMER_CLOCK1 | TC_CCR_CLKEN | TC_CMR_CPCTRG & ~(TC_CMR_WAVE);
|
||||||
/* disable the quadrature decoder, to route the IO pins of TIOA and TIOB directly to the timer counter function (36.6.14.1) */
|
/* disable the quadrature decoder, to route the IO pins of TIOA and TIOB directly to the timer counter function (36.6.14.1) */
|
||||||
TC0->TC_BMR &= ~(TC_BMR_QDEN);
|
TC0->TC_BMR &= ~(TC_BMR_QDEN);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user