Hi, I am a newbie. I try to figure out how to use the Timer Counter peripheral in ATSAMV71Q21. For my first step, I would like to turn on the Timer Counter peripheral and see it count. I was using TC0 channel 0. I selected internal SLCK clock, and then enable the Timer Counter by setting the CLKEN bit in TC_CCR0. I expected the value in TC_CV0 change, but it never happened. By the way, I am using SAMV71 Xplained board. I did see the TC_CMR0 value change in the I/O window after the write, so I think my code did do the write as I expected. I guess the Timer Counter does not count because I miss some setting. Any help will be appreciated.
Here is my code:
#define ADDR_TC_CCR0 0x4000C000
#define REG_TC_CCR0 (*((volatile uint32_t *)ADDR_TC_CCR0))
#define ADDR_TC_CMR0 0x4000C004
#define REG_TC_CMR0 (*((volatile uint32_t *)ADDR_TC_CMR0))
#define ADDR_TC_CV0 0x4000C010
#define REG_TC_CV0 (*((volatile uint32_t *)ADDR_TC_CV0))
/* Initialize the SAM system */
/* Replace with your application code */
REG_TC_CMR0 = 0x4; // clock selected: internal SLCK clock signal
REG_TC_CCR0 = 0x1; // set CLKEN to enable counter clock
REG_TC_CCR0 = 0x5; // I also try software trigger, but it still does not count.
while(REG_TC_CV0 == 0);
REG_TC_CCR0 = 0x2; // set CLKDIS to disable counter clock