|
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); }
|