PIC 16F628A Speaker sound
===

I'm trying to understand code below on this link. This program generates 800 Hz sound on speaker. I don't understand how to calculate frequency (it must be something with variables `impuls` and `timer` ). This code is for PIC16F628A , it has external oscillator set at 4Mhz.

   [source](http://pastebin.com/BvZ3TWe3)