Chips have internal timers which can be configured programmatically so they emit hardware interrupt in specified time intervals. When the interrupt is emitted, CPU jumps to the method which executes the certain program. After that it goes idle, waiting for the next cycle.