16F877A timer to capture in microseconds


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    And you changed the TickCount Interrupt Handler to account for the fact that Hundredths are now Thousandths and changed the variable from a byte to a word and ensured everything is ticking in 1mS steps? Or have you just changed the pre-load valve and hoped everything would work?

  2. #2
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    I only made changes to the pre-load value, LCDOUT command to display up to 3 digits and the tickcount interrupt handler, where I put in the new:

    Tickcount changes:
    If RunningFlag=1 then
    Thousandths=Thousandths+1

    If Thousandths>9 then
    Thousandths=0
    Hundredths=Hundredths+1

    etc....

    LCDOUT Changes:
    LCDOUT $FE, $C0, DEC3 Thousandths, " Thousandths"

    It doesn't seems right. What went wrong? Did I miss out anything? Getting 1ms counts is very critical for my project, but I just couldn't figure it out.
    Last edited by sycluap; - 20th December 2007 at 06:54.

  3. #3
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Anyone can help me on this?

  4. #4
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Is there anyway to add assembly language to the codes in PicBasic Pro? Can anyone guide me to do polling using timer 1 in 1ms interval?

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yes it's possible to mix assembler. you just need to use ASM/ENDASM
    Code:
    	ASM
    	' your asm code goes here
    	ENDASM
    Unless you define your variable as SYSTEM var, your PBP variable must have an underscore before them
    Code:
    	YourVar VAR BYTE
    
    	ASM
    	' your asm code goes here
    	CLRF _YourVar
    	ENDASM
    And PBP don't appreciate BANKSEL. you must use CHK?RP instead
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    thanks mister_e, this will help me in experimenting the 1ms interval polling. Is there anyone can help me on how to get 1ms interval by polling method for timer1?

  7. #7
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    I modified the Olympic Timer program, by replacing the:
    TMR1RunOn.HighByte= $FC
    TMR1RunOn.LowByte=$18

    and deleted the TMR1RunOn=TMR1Preset+TMR1RunOn, to directly load the TIMER1 preset value into the timer1 register.

    This make the timer by the program runs faster than used to. Until I change the value to $FF,$FE, the timer can have the timing interval very close to 1ms, but still slightly delayed, as I compare the timing (seconds) with a watch. The watch is about 2x faster than the timing by the timer.

    Attached is the code I wrote by referring to the Olympic Timer by Melanie. Is there any problem with the code? Any solution for that? Thanks in advance.
    Attached Files Attached Files
    Last edited by sycluap; - 12th January 2008 at 13:08.

Similar Threads

  1. mS Timer
    By whmeade10 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th September 2020, 12:12
  2. Using hardware capture
    By Bruce in forum Code Examples
    Replies: 14
    Last Post: - 25th March 2012, 05:52
  3. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  4. Measuring change of frequency with PIC
    By Aussie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th July 2007, 01:47
  5. Reaction timer using 16f877a and pbp
    By sphinxifm in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th July 2007, 14:28

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts