Problems with DT interrupts (PT_INT interrupt)


Closed Thread
Results 1 to 9 of 9
  1. #1

    Angry Problems with DT interrupts (PT_INT interrupt)

    Hello everyone

    I'm trying to use Instant Interrupts with the PT_INT interrupt (PWM time base) in my code.

    I'm using a 18F2431 with a 40MHz clock frequency. My PWM interrupt frequency is about 15kHz (PTPER=333).

    With a code like that (with no interrupt, just waiting the PIR3.4 flag in a loop), it works very well :

    Code:
    DEFINE OSC 40
    
    ' PCPWM registers configuration                                     
    PTCON0=%00000010        
    PTCON1=%10000000
    PWMCON0=%01000000
    PWMCON1=%00000001
    DTCON=%00110110
    PTPERH=$1:PTPERL=$4d
    
    ' PWM ISR
    pwmint:
    
    ' Wait PIR3 interrupt
    while PIR3.4=%0
    wend
    PIR3.4=%0
    .
    .
    .
    (there is my PWM code)
    .
    .
    .
    GOTO pwmint
    However, this code below should give me the same results and execute my PWM ISR at each PWM pulse, but it doesn't work :

    Code:
    DEFINE OSC 40
    
    INCLUDE "DT_INTS-18.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts
    
    ' PCPWM registers configuration                                     
    PTCON0=%00000010        
    PTCON1=%10000000
    PWMCON0=%01000000
    PWMCON1=%00000001
    DTCON=%00110110
    PTPERH=$1:PTPERL=$4d
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   PT_INT,  _pwmint,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @ INT_ENABLE PT_INT
    
    ' PWM ISR
    pwmint:
    
    ' Wait PIR3 interrupt
    PIR3.4=%0
    .
    .
    .
    (there is my PWM code)
    .
    .
    .
    @ INT_RETURN
    I need help thanks

  2. #2
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Problems with DT interrupts (PT_INT interrupt)

    Hey, you don't have any loop in you code.
    Code:
    DEFINE OSC 40
    
    INCLUDE "DT_INTS-18.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts
    
    ' PCPWM registers configuration                                     
    PTCON0=%00000010        
    PTCON1=%10000000
    PWMCON0=%01000000
    PWMCON1=%00000001
    DTCON=%00110110
    PTPERH=$1:PTPERL=$4d
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   PT_INT,  _pwmint,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @ INT_ENABLE PT_INT
    
    Main:
    GOTO Main
    
    ' PWM ISR
    pwmint:
    
    ' Wait PIR3 interrupt
    PIR3.4=%0
    .
    .
    .
    (there is my PWM code)
    .
    .
    .
    @ INT_RETURN
    With this code, you stay in main, and wait for interrupt. When interrupt fire PC will jump to to pwmint. And with INT_RETURN you return to main.
    Without Main loop, PIC execute every instruction, and when execute INT_RETURN processor reset PIC(reset on stack underflow).

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Problems with DT interrupts (PT_INT interrupt)

    Thanks a lot Pedja!

    I didn't know that a main loop was mandatory in order to execute an interrupt

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Problems with DT interrupts (PT_INT interrupt)

    However what's that "reset flag"?

    Do I need to clear myself the PIR3.4 flag?

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Problems with DT interrupts (PT_INT interrupt)

    Hi,
    When you tell DT-INTS to clear the flag (by setting the reset flag option to YES) you don't need to clear it manually in the ISR. If you set the option to NO then DT-INTS will leave the flag alone and its up to you (or the hardware) to handle it the flag as needed.

    /Henrik.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Problems with DT interrupts (PT_INT interrupt)

    Thanks Henrik

    I will let the DT-INTS clear the flag, I think it's more "efficient" than clear the flag manually...

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Question Re: Problems with DT interrupts (PT_INT interrupt)

    Nevermind...

    Robert
    Last edited by Demon; - 8th October 2014 at 18:37. Reason: dummy at keyboard

  8. #8
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159


    Did you find this post helpful? Yes | No

    Default Re: Problems with DT interrupts (PT_INT interrupt)

    Quote Originally Posted by Demon View Post
    Nevermind...
    Last edited by Demon; Today at 12:37. Reason: dummy at keyboard
    Robert
    I'm glad someone else feels the same way I do when I try to answer things!
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Problems with DT interrupts (PT_INT interrupt)

    I had quoted Pedja thinking I had selected the OP and saw nothing wrong with the Main routine.

    Robert

Similar Threads

  1. Replies: 5
    Last Post: - 3rd August 2014, 10:36
  2. Interrupt problems!
    By amindzo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd November 2006, 14:55
  3. Replies: 1
    Last Post: - 1st November 2006, 03:11
  4. RB0 interrupt problems
    By amindzo in forum General
    Replies: 1
    Last Post: - 26th August 2006, 11:52
  5. Problems with 16F876 on interrupts an WRITE / READ
    By BigWumpus in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th December 2005, 14:38

Members who have read this thread : 1

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