This commit is contained in:
Sem van der Hoeven
2023-11-03 00:25:00 +01:00
parent 923e82d0cf
commit 5e934a19f1
2 changed files with 8 additions and 3 deletions

View File

@@ -119,7 +119,8 @@ void setup()
pinMode(LED_BUILTIN, OUTPUT);
obd2_RTT_init();
obd2_TC_init();
statemachine_register_state(&init_state, STATE_INIT);
statemachine_register_state(&main_state, STATE_CAR_INFO);
statemachine_init();

View File

@@ -46,8 +46,12 @@ void obd2_RTT_set_period(__UINT32_TYPE__ period)
void obd2_TC_init()
{
/* enable the timer/counter 0 */
TC0->TC_CHANNEL[0].TC_CCR |= TC_CCR_CLKEN;
/* disable write protection */
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) */
TC0->TC_BMR &= ~(TC_BMR_QDEN);
}