From 923e82d0cf3aa379b6ab62bd5b1e9e46d0930bb9 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Tue, 31 Oct 2023 23:15:18 +0100 Subject: [PATCH] Add TC start --- due_obd2/obd2_timer.c | 11 ++++++++++- due_obd2/obd2_timer.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/due_obd2/obd2_timer.c b/due_obd2/obd2_timer.c index f0faa59..379ec62 100644 --- a/due_obd2/obd2_timer.c +++ b/due_obd2/obd2_timer.c @@ -1,3 +1,4 @@ +#include "sam3xa/include/component/component_tc.h" #include "obd2_timer.h" void obd2_RTT_init(void) @@ -45,6 +46,14 @@ void obd2_RTT_set_period(__UINT32_TYPE__ period) void obd2_TC_init() { - /* enable the timer/counter 0*/ + /* enable the timer/counter 0 */ TC0->TC_CHANNEL[0].TC_CCR |= TC_CCR_CLKEN; + /* 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); +} + +void obd2_TC_start() +{ + /* software trigger the timer reset it and start the clock */ + TC0->TC_CHANNEL[0].TC_CCR |= TC_CCR_SWTRG; } diff --git a/due_obd2/obd2_timer.h b/due_obd2/obd2_timer.h index c4289b3..4853818 100644 --- a/due_obd2/obd2_timer.h +++ b/due_obd2/obd2_timer.h @@ -16,6 +16,7 @@ void obd2_RTT_enable(); void obd2_RTT_set_period(__UINT32_TYPE__ period); void obd2_TC_init(); +void obd2_TC_start(); #ifdef __cplusplus }