Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Timer1, CC5X & 16F631

Status
Not open for further replies.

Nayth

New Member
Hi

I'm trying to understand how to make the timer1 work

I have input on PORTA.4 and it pulses, and I want to check if there's more or less than 10 seconds between the pulses

Code:
TMR1CS = 0; //internal clock
TMR1ON = 1; //enables TIMER1
T1OSCEN = 0; //oscillator is shut-off
TMR1H = 0x00;
TMR1L = 0x00;

Then I thought I could do something like

Code:
if(Timer1 > 10)
{
 //Do Stuff
}else{
 //Do something else
}

I know the above code wont work and this is where I need your help, cause I just can't seem to find any info about how to set up Timer1 and then check how far it's counted.

Please write if I should supply more code
 

Nayth

New Member
If I set
Code:
TMR1H = 0xFDE8;

Shouldn't it count to 65,000 and then roll over?

Another questen is, why is my program slowing down when I execute this command?
Code:
TMR1IF = 0;

That command should reset the interrupt flag for the timer, no?

I'm so lost with this Timer1, please help if you can

Thanks in advance
 

Nayth

New Member
Same slowdown if I use
Code:
T1IF = 0;

I can't crack my head around why it slows down when I call that function

There's no slowdown when I reset the interrupt bit for Timer0

Anybody have an idea?
 
Last edited:

Nayth

New Member
I also get an error saying that
Code:
Symbol 'TMR1' is undefined

Anybody know what that is, and what I can do about it?
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top