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: chaining two 16bit timers to get 32bits in ATSAM3U4E?
PostPosted: Wed Apr 20, 2011 5:20 pm 
Offline

Joined: Wed Mar 30, 2011 10:25 pm
Posts: 3
Hello,

I'm trying to get T2 chained to T1 so T2 is the upper counter.
T1 works fine and I've tried several values for the MBR and CMR for T2 to
count using TIOA1 via XC2 as the clock input using TIOA1 output from T1.
Not having much luck so far.

void TC_ConfigureSpecial(AT91S_TC *pTc, unsigned int BMR, unsigned int CMR)
{
// Disable TC clock
pTc->TC_CCR = AT91C_TC_CLKDIS; // will reenable later
// Disable interrupts
pTc->TC_IDR = 0xFFFFFFFF;
// Clear status register
pTc->TC_SR;
pTc->TC_BMR = BMR;
// Set mode
pTc->TC_CMR = CMR;
}

void ConfigureTC1_TC2(void)
{
#define WAVE 0x00008000

#define CMR1 0x00008003 // Timer_clock4
#define BMR1 0x00000000 //

#define CMR2 0x47 // XC2 as clock input, rising,
#define BMR2 0x00000020 // TIOA1 connected to XC2

// ---------- Configure Timer1 for the lower 16-bits
// Enable peripheral clock
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_TC1;
TC_ConfigureSpecial(AT91C_BASE_TC1, BMR1, CMR1 ); // 3 = MCK/128,96MHz/128/2 = 375Khz resolution

// ----------- Configure Timer2 for the upper 16-bits
// Enable peripheral clock
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_TC2;
TC_ConfigureSpecial(AT91C_BASE_TC2, BMR2, CMR2); // select TIO1 as input from Timer1

//
// Start the counter.
TC_Start(AT91C_BASE_TC2); // start the upper because the lower will start first
TC_Start(AT91C_BASE_TC1);

}


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: No registered users and 1 guest


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:  
cron