Hi All,
//Using 12f675
related setting are as follows:
__CONFIG(FOSC_INTRCIO)//internal oSC,
OPTION_REG = 0x88; //pullups are disabled
//timer0 clock source is internal
//timer0 perscaller is 1:1 (disabled "assigned to WDT")
with the above settings author of the code for nec protocol receiver,
is considering TICKS PER MS is 1004.
// #define TICKSPERMS 1004 // tick in a milli second
how did it come??
and what actualy mean sysTick and TimerTick??
can anybody let me update the matter..
tnx
let me clear first::
As Pic is 12f675 and the "//__CONFIG(FOSC_INTRCIO)//internal oSC," so it is operating at 4Mhz.
//OPTION_REG = 0x88;// so, PSA is 1 and it is assined to WDT, where TMR0 prescaler is disable here ; TMRO clock source is internal; pullup enable.
as x-tal frq is 4mhz->sys frq is (4/4)1mhz -> this 1 mhz directly come to Timer as prescaler for timer is disable as stated above. >>am i right?
So, TICKS PER uSEC is comming to 1.0
and TICKS PER MS => 1000.0
and timer overflow happen at 256 Ticks/256u SEC.
PLEASE Suggect if i am wrong???
If my review are correct, then what is conceptual meaning of
sysTick and TimerTick??
Actually my question was :
author of the code below for nec ir protocol receiver,
is considering TICKS PER MS is 1004.-->> How it is coming at 1004 instead of 1000.
is there anything is happening which i am not considering here??
// Global includes
#include <htc.h>__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & CP_OFF & CPD_OFF);
/*
*
*/
#define LED GPIObits.GPIO5 // IR port status indicator LED defination
#define RELAY1 GPIObits.GPIO0 // RELAYS PORT definations
#define RELAY2 GPIObits.GPIO1
#define RELAY3 GPIObits.GPIO2
#define RELAY4 GPIObits.GPIO4#define IRSENSOR GPIObits.GPIO3 // IR PORT defination
//#define TICKSPERMS 1004 // tick in a milli second
#define TICKS11ms 11044 // ticks in 11ms
#define TICKS5o5ms 5522 // ticks in 5.5ms
#define TICKS2o3ms 2309 // ticks in 2.3ms
#define TICKS3ms 3012 // ticks in 3sm
#define TICKS0o2ms 200 // ticks in 0.2ms
#define TICKS8ms 8032 // Tickunsigned int TIMEOUT = TICKS11ms; // the pulse should occur before this time excede Otherwise it is an error
unsigned int PREPULSE = TICKS8ms; // the interrupt should occur after this time Otherwise it is an error
Please suggest..
tnx
let me clear first::
As Pic is 12f675 and the "//__CONFIG(FOSC_INTRCIO)//internal oSC," so it is operating at 4Mhz.
//OPTION_REG = 0x88;// so, PSA is 1 and it is assined to WDT, where TMR0 prescaler is disable here ; TMRO clock source is internal; pullup enable.
as x-tal frq is 4mhz->sys frq is (4/4)1mhz -> this 1 mhz directly come to Timer as prescaler for timer is disable as stated above. >>am i right?
Upto here you are all correct but then
So, TICKS PER uSEC is comming to 1.0
This is not true, as you said the timer will over flow for every 0-256 Ticks which is 0-256u Sec. The problem here is you are comparing microcontroller ticks with real world time which will not hold because the PIC counts from 0 to 256 everytime it gets reseted. This "0" should also be inculded in the count. If you do it you will agree with the author that it is 1004 ticks for one ms.
Because if you check how many zeros will be there in 1000 (1 ms) it is 1000/256 = 3.9 which the author has rounded to 4. Hope this clears your question
yes aswinth thmks for your valued knoledge. thks for clear my doubt on the matter.
likewise, 256usec req for 257 count("0" incl zero, ie, 256+1=257)
and thats , for 1000usec --> will [(257/256)*1000] = 1003.9 = = 1004 counts.
once again tnks for clearing my complesity.
Jayant
Permalink// #define TICKSPERMS 1004 // tick in a milli second
This basicaly means the timer is overflowing for every 1004 milli second rising an Timer interrupt.
To know how it came you should check the status of OPTION_REG here
OPTION_REG = 0x88; same in binary form is OPTION_REG = 0x10001000;
This means that prescaler is 2 and clock frequency is FOSC/4.
So to know how the value of 1004 came you should know what crystal your PIC is running on then use the formulae
Delay = ((256-REG_val)*(Prescal*4))/Fosc to calculate the delay value
- Log in or register to post comments
Joined May 19, 2015 213Tuesday at 03:45 PM