want help in understanding program

I want help inunderstanding below code.
please help if anyone can.

void setup ()
{
pinMode (9, OUTPUT) ;
pinMode (10, OUTPUT) ;
  TCCR1A = 0xE2 ;  
  TCCR1B = 0x1A ;  
ICR1  = 20000-1 ;  
  OCR1A = 10000-1 ;  
  OCR1B = 10000-1 ;  
  TCNT1 = 0x0000 ;
}

void loop ()
{}

The code sets registers in the Arduino's counter timer 1. The processor used in the Uno has three of these called 0, 1 & 2.
However it is not doing it correctly the 10000 - 1, is a stupid thing to do with an 8 bit register.
To see the possibilities of the timers see the 328 processor data sheet.

Have a read here, may help you some what.

Chrisbee:
Have a read here, may help you some what.

sir @chrisbee , i am phasing difficulty in understanding below part of code.

ICR1 = 20000-1 ;
OCR1A = 10000-1 ;
OCR1B = 10000-1 ;
TCNT1 = 0x0000 ;

this is program for generating a square wave of value 100. this 100 value i am getting , i can't found that it is in hertz or bits/second means i should believe this as a frequency or datarate. please help me sir.

i am phasing difficulty in understanding below part of code.

ICR1 = 20000-1 ;

As I told you before this is rubbish.
ICR1 is an 8 bit register, this means it will hold numbers between 0 and 255.

20000-1 = 19999
which in hex is 0x4E1F
which means the value placed in the ICR1 register is 0x1F
Now if that is what the writer of this program wanted to do he would have put
ICR1 = 0x1F
But he didn't so what ever he was trying to do was very wrong. Do not try and understand this, it is rubbish. The same goes for the other assignments.

Timers work on clock pulses from the processor's clock that come through a prescale division first. The numbers in these registers are counts of pre scaled processor clocks of 16MHz.

Grumpy_Mike:
As I told you before this is rubbish.
ICR1 is an 8 bit register, this means it will hold numbers between 0 and 255.

It is not rubbish.

#define ICR1 _SFR_MEM16(0x86)
#define ICR1L _SFR_MEM8(0x86)
#define ICR1H _SFR_MEM8(0x87)

oqibidipo:
It is not rubbish.

#define ICR1 _SFR_MEM16(0x86)

#define ICR1L _SFR_MEM8(0x86)
#define ICR1H _SFR_MEM8(0x87)

please help me to understand sir @oqibidipo , if you can explain, i am in confusion in both answer.

oqibidipo:
It is not rubbish.

The code as posted IS rubbish.

If the OP would bother to post ALL the code maybe some of it would make sense.
I look forward to your explanation.

Grumpy_Mike:
The code as posted IS rubbish.

If the OP would bother to post ALL the code maybe some of it would make sense.
I look forward to your explanation.

It is most definitely not rubbish. ICR1, OCR1A, and OCR1B are all 16-bit registers. Their 8-bit components have H and L suffixes. oqibidipo's extract shows the way the ICR1 registers are declared in the chip's header file. ICR1 uses the _SFR_MEM16, and the L and R registers use _SFR_MEM8. OCR1A and OCR1B will have very similar declarations.

this is program for generating a square wave of value 100. this 100 value i am getting , i can't found that it is in hertz or bits/second means i should believe this as a frequency or datarate. please help me sir.

The timer has been set up in a mode which is fast pwm to ICR1 where ICR1 is the top value where the timer resets. The timer prescaler is set to 8 which is .5 microsecond/tick.

ICR1 is set to 20000 - 1. The count is zero referenced so 19999 produces 20000 ticks at .5us/tick. That gives a 10ms period or 100 Hz frequency for the timer repeat.

Two outputs have been set up at 50% duty cycle (determined by OCR1A,OCR1B) with opposite phasing.

Grumpy_Mike:
The code sets registers in the Arduino's counter timer 1. The processor used in the Uno has three of these called 0, 1 & 2.
However it is not doing it correctly the 10000 - 1, is a stupid thing to do with an 8 bit register.
To see the possibilities of the timers see the 328 processor data sheet.

ICR1, OCR1A and OCR2A are 16 bit registers on the ATmega328, I use them all the time.

cattledog:
The timer has been set up in a mode which is fast pwm to ICR1 where ICR1 is the top value where the timer resets. The timer prescaler is set to 8 which is .5 microsecond/tick.

ICR1 is set to 20000 - 1. The count is zero referenced so 19999 produces 20000 ticks at .5us/tick. That gives a 10ms period or 100 Hz frequency for the timer repeat.

Two outputs have been set up at 50% duty cycle (determined by OCR1A,OCR1B) with opposite phasing.

means at pin 9, from referance 0 to 9999 it will be high and after that it will be low on pin 9.

can i say it datarate of 100 bits/second? or how can i find the datarate of this square wave.

can i say it datarate of 100 bits/second? or how can i find the datarate of this square wave.

The code fragment outputs two square waves. The frequency of each square wave is 100 Hz. One is high while the other is low and one is low while the other is high.

I'm not clear to me what you mean by data rate. How will information be transmitted. Are you talking about bits/second of the two square waves or each one individually? Please explain more.

cattledog:
The code fragment outputs two square waves. The frequency of each square wave is 100 Hz. One is high while the other is low and one is low while the other is high.

I'm not clear to me what you mean by data rate. How will information be transmitted. Are you talking about bits/second of the two square waves or each one individually? Please explain more.

first of all i will thankful to you sir, @cattledog
sir, i am getting a square wave at pin 9 and 10 as you say in anti-phase means when one is high, other is low and vice versa. now sir i am only using the output from pin number 9 so i am using a square wave generated at pin number 9. i want to find out bits/second individually means want to find out data rate of the signal coming from pin 9.

urvishkumar:
first of all i will thankful to you sir, @cattledog
sir, i am getting a square wave at pin 9 and 10 as you say in anti-phase means when one is high, other is low and vice versa. now sir i am only using the output from pin number 9 so i am using a square wave generated at pin number 9. i want to find out bits/second individually means want to find out data rate of the signal coming from pin 9.

A square wave produces the same information from the beginning to the end of the universe. Thus it conveys no information, and has a data rate of 0. Your square wave is only on when the Arduino is on, so the maximum data rate is limited to how fast you can turn the Arduino on and off.

aarg:
A square wave produces the same information from the beginning to the end of the universe. Thus it conveys no information, and has a data rate of 0. Your square wave is only on when the Arduino is on, so the maximum data rate is limited to how fast you can turn the Arduino on and off.

no sir, square wave will definitely have some data rate because if we apply it to any other transmitter then it will transmit 1 and 0 according to square wave of 100 Hz so my question is can we say it a data rate?

urvishkumar:
no sir, square wave will definitely have some data rate because if we apply it to any other transmitter then it will transmit 1 and 0 according to square wave of 100 Hz so my question is can we say it a data rate?

Nope. It has a frequency, and conversely a period. Switching to the frequency domain, it has spectral content. It can also transfer power and energy. But, none of these properties changes as a function of time. Thus (per @aarg), it carries no information in the Shannon sense of the term.

Put another way, if you tell me the amplitude at time t=0, I can tell you with absolute certainty what the amplitude will be at time t = 100 billion years. Again, no information content. Hence data rate = 0.

urvishkumar:
first of all i will thankful to you sir, @cattledog
sir, i am getting a square wave at pin 9 and 10 as you say in anti-phase means when one is high, other is low and vice versa. now sir i am only using the output from pin number 9 so i am using a square wave generated at pin number 9. i want to find out bits/second individually means want to find out data rate of the signal coming from pin 9.

A square wave is not, in and of itself, information, so it doesn't have a data rate. You can certainly use a square wave as a test signal in place of information, but the equivalent data rate depends on the protocol you are simulating with it. You have not specified the protocol that is used to interpret the information, so there's no way to assign them a data rate.

The generated square waves have a frequency of 100 Hz and opposite polarity. That's all that can be said about them right now.

Actually by generating above code we are getting a square wave, now from pin 9 we are connecting it to the 433MHz transmitter data pin so here as a point of view from the transmitter my information is square wave which i am getting from pin 9. at receiver i am getting this and by using below code we are getting a value 100 by using below syntax using arduin0 at 433MHz receiver side. both transmitter and receiver using the ASK technique of information transfer.

int input=12;
int high_time;
int low_time;
float time_period;
float frequency;

high_time=pulseIn(input,HIGH);
low_time=pulseIn(input,LOW);

time_period=high_time+low_time;
time_period=time_period/1000;
frequency=1000/time_period;
so now the information i am getting will have pulse at high time and no pulse at low time. so for high time it will count 1 and for low time it will count 0. so to total 100 Hz square wave data will have 100 time high and 100 time low so can't we say it a data rate of 200??

urvishkumar:
so to total 100 Hz square wave data will have 100 time high and 100 time low so can't we say it a data rate of 200??

Saying it doesn’t make it so.

You could also say that your 100 Hz square wave actually consists of 1,000,000 consecutive 1’s followed by 1,000,000 consecutive 0’s, repeating 100 times per second. Thus, your data rate is now 200,000,000 bits per seconds. Look at that, I just increased your data rate by a factor of 100,000!!!! I’ll send you a bill.