Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: AT91SAMG20 TC: is it capable to count pulses using TIOA?
PostPosted: Wed Nov 30, 2011 11:58 pm 
Offline

Joined: Thu Nov 17, 2011 10:21 pm
Posts: 2
I am having trouble to use TIOA0 as the source for the 16-bit counter, hope someone can give me some ideas.

I want to know if it is possible to count transitions on TIOA0, I have not seen a single answer on how to do so and I can't get it to count.

In the clock chaning diagram it shows that TC1 and TC2 can take as an input TIOA0.

Therefore I am choosing TC1 and the MUX as follows:

*TCB_BMR = AT91C_TCB_TC1XC1S_TIOA0;

Then for the TCCLKS MUX I select XC1.

Enable and SWTRG the TC1 but it nover counts and the Mirror TIOA and TIOAB in the status register never change...


So I end up with TC4, PB0_TIOA3 and XC1.

Here is the code

//PIO
*PIO_PDR = AT91C_PB0_TIOA3; //define PB0 TIOA3 as peripheral
*PIO_BSR = AT91C_PB0_TIOA3; //select peripheral B

*PMC_PCER = (DWORD)(1 << AT91C_ID_TC4); //*** enable timer 4 clock over PMC

//Disable the clock and the interrupts before to configure it
*TC_CCR = AT91C_TC_CLKDIS;
*TC_IDR = 0xffffffff;

//Clear the status bit
dummy = *TC_SR;

*TCB_BMR = AT91C_TCB_TC1XC1S_TIOA0;

//Set the mode ;
*TC_CMR = AT91C_TC_CLKS_XC1;

//Enable the clock and start it with a software trigger
*TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;

What am I doing wrong?

Thx


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: