Menu

Timer 0 as Counter

2009-01-22
2013-05-30
  • Nobody/Anonymous

    Hi all. I'm trying to use hardware timer0 in counter mode on board a 16F74 to measure an external frequency.

    I read the pic data sheet, and understand if I set the prescalar to 1:1 and input the signal to RA4/T0CK1 it should work?

    I'm looking at the timer function commands, and I figure it should go something like this:

    InitTimer0 (Ext, PSO_1/1)         ; I'll use 1/2 if necessary and
                                                     ; double the sample period

    Clear timer                               ; Set to 0

    Wait Sampleperiod                   ; Wait for the count to build up

    Ok, now I'm at an impasse. How do I read the value of the register (Called TMRO in the PIC) into a variable so I can use it?

    Thanks for any advice,

    Chay

     
    • Hugh Considine

      Hugh Considine - 2009-01-23

      In GCBASIC a register is a variable, so you can just use TMR0 like any other variable.

       
    • Nobody/Anonymous

      Thanks for the advice.

      I found the usage in the online help section.

      I should have looked there first!

      Chay

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.