The following piece of code deals with CPU Timer 2 a. What does each line of cod
ID: 3744050 • Letter: T
Question
The following piece of code deals with CPU Timer 2 a. What does each line of code do? (see section 2.14.2 CPUTIMER REGS Registers in the technical reference manual) (Hint: One or more lines may do nothing. but you must indicate which lines do nothing.) b. What period (in ns) will CPU Timer 2 have after this code is done executing (assume no prescaling is done)? cpuTimer2Regs . TCR . bit. TSS = 1; CpuTimer2Regs. PRD.all199; CpuTimer2Regs.TCR.bit.TRB0; CpuTime r 2Regs . TCR . bit . TIE = 0; cpuTimer2Regs . TCR . bit. TRB = 1; cpuTimer2Regs . TCR . bit. TSS = 0;Explanation / Answer
a.
CpuTimer2Regs.TCR.bit.TSS=1 // Start Timer
CpuTimer2Regs.PRD.all=199 // Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
CpuTimer2Regs.TCR.bit.TRB=0 // Does nothing
CpuTimer2Regs.TCR.bit.TIE=0 // Disable Timer1 interrupt
CpuTimer2Regs.TCR.bit.TRB = 1 // Read 32-Bit Timer Value
CpuTimer2Regs.TCR.bit.TSS=0 // Stop Timer
b.
4.294967295 ns
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.