frequency = ((unsigned long)get_timer0()<<8) + prescaler;
frequency = ((unsigned long)get_timer0()<<8) || prescaler;
T0IF = 0;while(!TOIF){output_high(input_gate);output_low(input_gate);n++;}
frequency = ((unsigned long)get_timer0()<<8) || (255 - n);//display frequency to LCD
since prescaler is 8-bit, the lineCode: [Select]frequency = ((unsigned long)get_timer0()<<8) + prescaler;should be Code: [Select]frequency = ((unsigned long)get_timer0()<<8) || prescaler;but the actual 8-bit prescaler is not readable. Also, hindi ba fixed ang value ng prescaler (256)? Hindi na yata kailangan ang line na prescaler--; sa loob ng do while loop
frequency = ((unsigned long)get_timer0()<<8) | prescaler;
while(true){ //initialize prescaler_counter = 0; set_timer0(0); //getting TMR0 Value output_float(input_gate); //enable input delay_ms(200); //gating time output_low(input_gate); //disable input oldTMR0 = get_timer0(); frequency = oldTMR0 * 256; //pwede ring "frequency = oldTMR0 << 8;" //getting the prescaler value while(oldTMR0 == newTMR0) //test if tmr0 has incremented { output_high(input_gate); //self clocking output_low(input_gate); prescaler_counter++; // count until TMR0 incremented newTMR0 = get_timer0(); } frequency += (256 - prescaler_counter); display_reading();}
output_high(input_gate); //self clocking output_low(input_gate);
output_high(input_gate); //self clockingdelay_cycles(1); // NOP (4 osc clock)output_low(input_gate);delay_cycles(1);
setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_256);
//getting TMR0 Value output_float(input_gate); //enable input delay_ms(200); //gating time output_low(input_gate); //disable input
pwede na ang isang NOP? Code: [Select]output_high(input_gate); //self clockingdelay_cycles(1); // NOP (4 osc clock)output_low(input_gate);delay_cycles(1);
lagyan mo pala ng konteng nopsin between Code: [Select] output_high(input_gate); //self clocking output_low(input_gate);baka hindi makilala ng input.
sir paranz ok lang din yung "+",
while(oldTMR0 == newTMR0)
while(!T0IF)
yup at saka hindi overflow aabangan natin kundi yung change (incerement by 1) sa timer0. Well on the second thought overflow pa rin un, hehehe, overflow ng prescaler not the timer,hehehehe
.. tama po yan, as you may have notice way below clock frequency na ang input frequency, ibang method/technique ang ginamit nya pagsukat..
while(true) { prescaler_counter = 0; oldTMR0 = get_timer0(); sprintf(str2," Hz"); if(get_pulses(1)==0) { if(get_pulses(5)==0) { if(get_pulses(50)==0) { if(get_pulses(200)==0) { oldTMR0 = get_pulses(1000); } else{ oldTMR0 = get_pulses(200); sprintf(str2," Khz100to10"); } } else{ oldTMR0 = get_pulses(50); sprintf(str2," Khz1Kto100"); } } else{ oldTMR0 = get_pulses(5); sprintf(str2," Mhz10to1"); } } else{ oldTMR0 = get_pulses(1); sprintf(str2," Mhz50to10"); } do { output_high(input_gate); //self clocking delay_cycles(1); output_low(input_gate); delay_cycles(1); prescaler_counter++; // count until TMR0 incremented }while( get_timer0()==oldTMR0 && prescaler_counter<=256); frequency = ((unsigned long)oldTMR0<<8) + (256 - prescaler_counter) - 1; display_reading(); }
unsigned int get_pulses(unsigned char gate_time){ set_timer0(0); output_float(input_gate); delay_ms(gate_time); output_low(input_gate); return get_timer0();}