interrupt trouble @.1ms


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51

    Default interrupt trouble @.1ms

    i tried to get an interrupt at .1ms using dt-ints.

    i used 16f877a at 4MHz and timer1 1:1 prescaler , want to toggle a led that connected to portb.7 to test interrupt.

    timer1 pre-load value is 65437. The signal must be 5KHz , but it is about 2.4KHz.

    The code is below.What am i missing or what is the mistake?

    Code:
        INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
        INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
        
        
        LED     VAR PORTB.7
        
        OUTPUT  LED
        
        ADCON1      = 7
        
        
        
        
        
        ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler     TMR1_INT,       _TMR1_INT, PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
        ENDASM
    
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    
    
        T1CON = %00000101                ; Prescaler = 1, TMR1ON
    
        TMR1L = $9D         ; TMR1 = 65437
        TMR1H = $FF
    
        
        MAIN :
        
        PAUSE 50
       
    GOTO MAIN
        
        
        TMR1_INT :
        
        TMR1L = $9D
        TMR1H = $FF
        
        TOGGLE LED
    @ INT_RETURN

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    When you load the timer, you have to load the High Byte first, then Low Byte.
    Charles Linquist

  3. #3
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    When you load the timer, you have to load the High Byte first, then Low Byte.
    thanks charles for your quick reply.

    i tried to load highbyte of timer1 first , but it is not the aid.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    You forgot to take the reload time into account ...

    from MrE calc. I get 65443 ...

    Why not use a 8 bits timer w/ preload = 63 ???

    Alain
    Last edited by Acetronics2; - 24th March 2009 at 17:51.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    Why not use a 8 bits timer w/ preload = 63 ???

    Alain
    i used timer0 , the problem is the same.

    i used darrel taylor's intterrupt system before , but the interrupt durations was so long about 20ms there was no problem.

    but when i want to use it 100 microseconds this problem occurred.

    thanks for your advice.

  6. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    1. I would remove "PAUSE 50" from main loop.
    2. To load the timer, have a word variable like timex.
    For example:

    Code:
    TimeX VAR WORD
    
    TimeX = 65437
    
    TMR1L = TimeX.LowByte
    TMR1H = TimeX.HighByte
    3. Why not use TMR0 ?


    ----------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  2. Replies: 10
    Last Post: - 2nd May 2009, 07:42
  3. Very Trouble with 8722 Interrupt
    By smarino in forum mel PIC BASIC
    Replies: 4
    Last Post: - 5th March 2009, 09:48
  4. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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