![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| hi guys, i m facing problem with timer
__________________ | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) | |
| Quote:
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | ||
| |
| | (permalink) |
| Unbelievable. Mike. | |
| |
| | (permalink) | |
| Quote:
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;
} 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 .....
__________________ | ||
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| wow.amazed you were able to read that code format | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) | |
| Quote:
What do you mean by initialize the second? PLZ send me some example code of initializing the second.
__________________ | ||
| |
| | (permalink) | |
| Quote:
What do you mean by initialize the second? PLZ send me some example code of initializing the second.
__________________ | ||
| |
| | (permalink) |
| i m using 4.00MHz cystal........
__________________ | |
| |
| | (permalink) |
| 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; Mike. | |
| |
| | (permalink) |
| C on top of that!!!!!!!!!! | |
| |
| | (permalink) | |
| Quote:
__________________ | ||
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| 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 |