I don't know why but I'm losing my mind trying to find out which libraries the timer clock defs are in. I wanted to say "buried in" or "hidden away" but that's just my incompetence typing and I know this.
This all started when I was trying to look up where "TC_CMR_TCCLKS_TIMER_CLOCK4" is referenced. I'm trying to understand how the registers are reference for the ATSAM3X8E.
This is the block of code I need to be able to understand beginning to end.
void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency) {
pmc_set_writeprotect(false);
pmc_enable_periph_clk((uint32_t)irq);
TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4);
uint32_t rc = VARIANT_MCK/128/frequency; //128 because we selected TIMER_CLOCK4 above
TC_SetRA(tc, channel, rc/2); //50% high, 50% low
TC_SetRC(tc, channel, rc);
TC_Start(tc, channel);
tc->TC_CHANNEL[channel].TC_IER=TC_IER_CPCS;
tc->TC_CHANNEL[channel].TC_IDR=~TC_IER_CPCS;
NVIC_EnableIRQ(irq);
}
I thought it would be in tc.h or tc_lib.h but I literally opened up every .h file inside my Arduino install folder and still couldn't find the defs from the above block of code. I got fed up and opened them all in notepad++ and did a search across all files for "TC_CMR_WAVSEL_UP_RC" and still couldn't find it. What am I missing here?
Reading this Atmel Timer Application Note isn't helping because I think I need to be using their platform and libraries.
Can someone confirm if at some point it makes sense to just move away from the Arduino IDE? I know the answer to most questions is "It depends."
It isn't clear to me if I can or should even use the Atmel Advanced Software Framework within Arduino but it it's at all possible to switch to Atmel studio and use the Arduino Due I may decide to cut my losses with the Arduino IDE because while it's wonderful for board and library management I'm really struggling to locate very basic info like library defs. Yes I know.. It's inexperience, and incompetence, and impatience but if I'm here it's because I'm 5hrs into trying to understand how to setup the timers so I can output user custom PWM signal with a minimum pulse with of 50nS.