First of all; What is the clock speed of internal clock (Mhz) of 18F4520? In the datasheet is written that is configurable. But I haven't configure nothing which refers to clock speed, because I can damage the chip.
Page 28 of DS39631A. The internal clock speed is whatever you configure it to be...from 31Khz, up to 32Mhz.
Second; How can I configure TMR0 (16bit mode) so that the output of one pin will toggle with the frequency of 4 Hz?
Can someone give an example for calculating the parameters for this particular chip. I am using the timer as 16 bit timer, I know that the internal clock for the timer is reduced 4 times, and then it can be reduced with the prescaler (which we configure).
Section 11 of DS39631A.
Break it down...
T0CON.6 = 0 = TMR0 is 16 bit counter
T0CON.5 = 0 = TMR0 source is the internal clock
T0CON.3 = 0 = TMR0 prescale is used
T0CON.2-0 = 001 = 1:4 prescale
Assume you're running 8 Mhz internal clock.
8 Mhz / 4 = 2Mhz which is the internal instruction clock cycle
2Mhz / 4 prescaler = 500khz
16 counter overflows every 65,536 counts
500khz / 65536 = 7.62939453125 Hz
Now you have to write code that uses either polling or an interrupt to check if the TMR0 counter overflowed and toggle a pin appropriately.
Without pre-setting the TMR0L & TMR0H bytes to a preset value each time the TMR0 overflows, you aren't going to get exactly 4Hz.
So, now write some code, some real code, and program it to a real PIC, on a real demo PCB of some sort, and report back.