BasicMicro - Forums

www.basicmicro.com
It is currently Sat Feb 04, 2012 6:43 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Nano 18 timers
PostPosted: Mon Aug 23, 2010 1:55 pm 
Offline
Citizen

Joined: Tue Aug 10, 2010 3:42 pm
Posts: 15
Does the nano18 have usable timers that I can use to record event timing?

The syntax manual posted on this forum on the nano18 does not mention them?

essentially I need to setup a m\s timer.


Top
 Profile  
 
 Post subject: Re: Nano 18 timers
PostPosted: Mon Aug 23, 2010 3:52 pm 
Offline
Citizen

Joined: Tue Aug 10, 2010 3:42 pm
Posts: 15
Mordred wrote:
Does the nano18 have usable timers that I can use to record event timing?

The syntax manual posted on this forum on the nano18 does not mention them?

essentially I need to setup a m\s timer.


I would like to use tmr1h:tmr1l internal, however even though I can see the registers I am unsure how to set it up to start and stop that timer and to set it to overflow at 2000 clock pulses (which acording to the syntax manual would be = to 1 ms) then use this to trigger a counter increase. I tried the example posted on a previous post however I could not get that example to work

tmr1h var byte
tmr1l var byte
Timer1 var word ; 16-bit variable created
Timer1.highbyte = TMR1H ; high byte of Timer1 is now TMR1's high-register, TMR1H
Timer1.lowbyte =TMR1L ; low byte of Timer1 is now TMR1's low-register, TMR1L
if timer1 = 2000 then
counter = counter+1
endif


Top
 Profile  
 
 Post subject: Re: Nano 18 timers
PostPosted: Tue Aug 24, 2010 9:11 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 784
Location: Temecula, CA
To do what you want to do would require an ISRASM{} interrupt handler, It's a fairly complex setup to use interrupts on the PICmicro. You need to read the 16F886/887 datasheet and find the TMR1 interrupt enable bit and the interrupt flag bit name. Then enable the interrupt and enable the GIE bit(global interrupt enable bit). You also need to write an ISRASM{} handler. This handler needs to clear the TMR1 flag bit, and then set the TMR1L and TMR1H registers to 65535-2000 so that after 2000 ticks an overflow(eg an interrupt) will happen. I think code like this has been posted in the past. Try searching through the forums for timer1 and see what comes up.

_________________
Nathan Scherdin
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO