Function to set up the timer
Exercise 6.2
Exercise 6 without CPU interaction