Hello everyone, Im using a ATSAML10E1A, I am using TC0 in 32-bit mode, and I would like to be able to read the COUNT register, To do this it is necessary to issue the READSYNC command first on CTRBSET register.
But for some reason Im not being able to modify the last 3 bits of this register.
So I cannot issue the READSYNC command, and the COUNT register never update.
I have tried several things, the first one I have tried is:
uint32_t time;
hri_tc_set_CTRLB_CMD_bf(TIMER_0.device.hw,TC_CTRLBSET_CMD_READSYNC_Val);
time = ((Tc *)TIMER_0.device.hw)->COUNT32.COUNT.reg;
As I said, this did not work, using the debugguer I managed to discover that the CTRBSET register was not changing, later, I tried this instead:
char *dir=(0x42001005); //CTRBSET register direction
*dir=(1<<7);
hri_tc_wait_for_sync(TIMER_0.device.hw, TC_SYNCBUSY_CTRLB|TC_SYNCBUSY_COUNT);
time = ((Tc *)TIMER_0.device.hw)->COUNT32.COUNT.reg;
This didn't work either (the bits in CTRBSET.CMD bits didn't change)
Finally I just tried to change de CTRBSET register to see if I was able to change it.
Using:
*dir=1;
worked and indeed change the first bit
*dir=1<<1;
This also worked, the second bit change, this worked for the third and sixth bit, but it didn't worked for the seventh nor eighth, furthermore I tried:
*dir = 0xff;
In a attempt to change all bits in CTRBSET register, but this just changed the first 3 bits, the latest 3 bits didn't change
Does anybody have any idea why this is happening and how I can set the CTRBSET.CMD in order to update the COUNT register?