Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void TC0_Handler(void){
- // Some code to read temperature.
- }
- void Init_Timer(){
- int n = 0;
- // Select Timer_Clock1 - Clear all first 7 bits for: clock selected: TCLK1
- *TC0_CMR1 = ~(~*TC0_CMR1 | 0x0007);
- // ETRGEDG: External Trigger Edge Selection - Edges
- *TC0_CMR1 |= 3 << 8;
- // ABETRG: TIOA External Trigger Selection
- *TC0_CMR1 |= 1 << 10;
- // LDRA: RA Loading Selection
- *TC0_CMR1 |= 2 << 16;
- // LDRB: RB Loading Selection
- *TC0_CMR1 |= 1 << 18;
- //TC1XC1S: External Clock Signal 1 Selection - Signal connected to XC1: TIOA0
- *TC0_BMR |= 2 << 2;
- // Enable pin B25
- *AT91C_PIOB_PER = 1 << 25;
- // Multiplex PB25 => TIOA0
- *AT91C_PIOB_ABMR = 1 << 25;
- *AT91C_PIOB_ABSR |= 1 << 25;
- NVIC_EnableIRQ(TC0_IRQn);
- // Enable interrupt
- // LDRBS: RB Loading
- *TC0_IER1 = 1 << 6;
- // Enable clock
- *TC0_CCR1 = 1 << 0;
- // Reset/Start clock
- *TC0_CCR1 = 1 << 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement