interrupt trouble @.1ms


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    1. I would remove "PAUSE 50" from main loop.
    ----------------
    I CHANGED IT TO "PAUSEUS 5" THE FREQUENCY OF SIGNAL IS SAME.


    Quote Originally Posted by sayzer View Post
    3. Why not use TMR0 ?
    ----------------
    I usually do this with tmr1 , there is not a special reason.
    i used tmr0 too , but the problem is going on.

    İLGİN İÇİN ÇOK TEŞEKKÜR EDERİM SAYZER.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Using a PBP interrupt eats hundreds of instruction cycles just saving & restoring PBP system
    variables.

    You can get much more accurate timing, and save hundreds of instruction cycles with a
    CCP Compare interrupt & .asm interrupt handler.

    Try something like this;
    Code:
      INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
      INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
        
        LED VAR PORTB.7
        OUTPUT LED
        LED = 1    
        ADCON1 = 7 
      
        ASM
    INT_LIST  macro    ; IntSource, Label,  Type, ResetFlag?
        INT_Handler     CCP1_INT,   CCP_INT, ASM,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
        ENDASM
    
    @ INT_ENABLE  CCP1_INT  ; enable Compare interrupt
    
        T1CON = %00000001   ; Prescaler = 1, TMR1ON
        CCP1CON = %00001011 ; compare mode, int when TMR1 = CCPR1
        CCPR1L = 100        ; interrupt every 100 instruction cycles
        CCPR1H = 0    
       
    MAIN:
        PAUSE 50
        GOTO MAIN
        
    ASM
    CCP_INT
        MOVLW  0x80     ; W = %10000000
        XORWF  PORTB,F  ; toggle RB7 on each interrupt
        INT_RETURN
    ENDASM
    This should give you a 5kHz signal on RB7, with Timer1 reset by hardware. To change the
    frequency, just change the value in CCPR1 high & low registers.

    See analyzer screen capture attached.
    Attached Images Attached Images  
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Default

    it is realy great bruce.

    I HAVE TO USE ASM INTERRUPTS AFTER THAT.

    The frequency is 5KHz.

    And where can i find some sample codes to use asm interrupt routines in PBP.

    thank you very much..

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    For examples of using assembler interrupts look at some of Darell Taylors code, and look
    through a few of the examples on MeLabs website.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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