Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 20th April 2008, 11:24 AM   (permalink)
Default difference in timing

hi guys,
i m facing problem with timer
__________________
hm:
sachin.kolkar is offline  
Old 20th April 2008, 11:50 AM   (permalink)
Default

A good example of a ridiculous post!
__________________
Agustín Tomás
In theory, there is no difference between theory and practice. In practice, however, there is.
atferrari is offline  
Old 20th April 2008, 12:05 PM   (permalink)
Default

Quote:
Originally Posted by sachin.kolkar
hi guys,
i m facing problem with timer
If it a boiled egg Timer, the sand has probably got damp..
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is online now  
Old 20th April 2008, 12:39 PM   (permalink)
Default

Unbelievable.

Mike.
Pommie is offline  
Old 21st April 2008, 05:07 AM   (permalink)
Question Difference in timing

Quote:
Originally Posted by Pommie
Unbelievable.

Mike.
i m sending my code
Code:
unsigned short counter,second,m;
 void main()
{
TRISB=0x00;
PORTB=0x0F;
T1CON=0b00001001;
TMR1H=0x80;
TMR1L=0x0F;
T1CON.TMR1ON=1;
PIR1.TMR1IF=0;
PIE1.TMR1IE=1;
INTCON=0xC0;
d0
{
 if(counter==30)
{
 counter=0;
second++;
if(second==60)
{
m++;
second=0;
if(m==1)
{
m=0;
PORTB=~PORTB;

}
}
}

}while(1);
}

void interrupt()
{
counter++;
TMR1H=0x80;
TMR1L=0x04;
PIR1.TMR1IF=0;
}
when i burn this programme to PIC16F72, first cycle it toggles at near 2mins,
for next cycles it exactly toggles at 1min...

is it tkes that extra time for boot up or what?
how can i overcome by this problem?
Plz help me .....
__________________
hm:
sachin.kolkar is offline  
Old 21st April 2008, 05:20 AM   (permalink)
Default

That is because you don't initialise counter or seconds in your code. Try setting them to zero at the start of your main routine.

Mike.
Pommie is offline  
Old 21st April 2008, 05:45 AM   (permalink)
Default

wow.amazed you were able to read that code format
Norlin is offline  
Old 21st April 2008, 06:30 AM   (permalink)
Default

The lack of initialisation was fairly obvious. The really confusing thing is the D0 (zero) instead of DO and the spurious closing braces. I assume this was introduced while copying.

Mike.
Pommie is offline  
Old 21st April 2008, 06:56 AM   (permalink)
Question

Quote:
Originally Posted by Pommie
That is because you don't initialise counter or seconds in your code. Try setting them to zero at the start of your main routine.

Mike.
do you mean that making TMR1L=0x00; TMR1H=0x00; is initializing the counter right ..........
What do you mean by initialize the second?
PLZ send me some example code of initializing the second.
__________________
hm:
sachin.kolkar is offline  
Old 21st April 2008, 07:02 AM   (permalink)
Question

Quote:
Originally Posted by Pommie
That is because you don't initialise counter or seconds in your code. Try setting them to zero at the start of your main routine.

Mike.
do you mean that making TMR1L=0x00; TMR1H=0x00; is initializing the counter right ..........
What do you mean by initialize the second?
PLZ send me some example code of initializing the second.
__________________
hm:
sachin.kolkar is offline  
Old 21st April 2008, 07:04 AM   (permalink)
Default

i m using 4.00MHz cystal........
__________________
hm:
sachin.kolkar is offline  
Old 21st April 2008, 07:58 AM   (permalink)
Default

Just set them to zero,
Code:
unsigned short counter,second,m;
void main()
{
    counter=0;
    second=0;
    TRISB=0x00;
    PORTB=0x0F;
    T1CON=0b00001001;
    TMR1H=0x80;
You might also consider setting m=0 as well.

Mike.
Pommie is offline  
Old 22nd April 2008, 02:26 AM   (permalink)
Default

C on top of that!!!!!!!!!!
donniedj is offline  
Old 23rd April 2008, 06:19 AM   (permalink)
Default

Quote:
Originally Posted by Pommie
Just set them to zero,
Code:
unsigned short counter,second,m;
void main()
{
    counter=0;
    second=0;
    TRISB=0x00;
    PORTB=0x0F;
    T1CON=0b00001001;
    TMR1H=0x80;
You might also consider setting m=0 as well.

Mike.
Thanx it working fine....
__________________
hm:
sachin.kolkar is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
PIC Timing baberjaved Micro Controllers 10 21st September 2007 02:06 AM
Timing Circuit with Relay Coded_Bananas Electronic Projects Design/Ideas/Reviews 6 6th October 2006 08:28 AM
Timing Diagram and waveform viewer available for PIC? janetsmith2000@yahoo.com Micro Controllers 7 12th August 2005 02:17 AM
Real difference: 16F628 and 16F628A eblc1388 Micro Controllers 14 23rd June 2005 11:42 AM
Difference of RC and LC filters Spectacular Butter General Electronics Chat 6 30th November 2004 12:39 PM



All times are GMT. The time now is 09:10 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker