DT_INT trying to use INT_INT, TMR1_INT, HPWM and lots of issues.


Closed Thread
Results 1 to 7 of 7

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Hi, LLMike,

    The first thing for me is ...

    HPWM max frequency with PBP is ...32767 Hz ...

    so, 40 Khz need to use the PWM module " hand configured " .


    The second one is ...

    DT Interrupts handles by itself the interrupt enable and disable ... as you answered YES for resetFlag ...


    The Third one is ...

    I would stop TMR1 as it continues to run ... first, to read it comfortably, and second, to avoid a timer overflow ... note you'll have to reset it somewhere ... sooooo ... HAVE to stop it !!!

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  2. #2
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Hi Acetronics,

    I saw in the PBP manual the 32767 Hz limit but when I do
    Code:
    HPMW 1,127,40000
    I get a straight 40KHz reading on the scope! could it be that it is a maximum suggested and that's why I burned my chip? Cause I would really like to figure out why I burned my chip.

    I've rewrote my code but obviously not been able to test until I receive my order.
    Does this make more sens?
    Code:
    @ __config _XT_OSC & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF
    clear
    DEFINE OSC 4
    FLAGS = 0
    TRISA = %00111
    TRISB = %00000001  
    CMCON = %110
    INTCON = %10011000
    OPTION_REG = %10000000
    TMR1H = 5535
    TMR1L = 0
    I var byte
    tTime var word
    
    
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ; Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,  _SignalDetect,   PBP,  yes
            INT_Handler   TMR1_INT,  _SignalTimeOut,   PBP,  yes
    
            endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   INT_INT     ; enable external (INT) interrupts
    @   INT_ENABLE  TMR1_INT     ; Enable Timer 1 Interrupts 
    
    
    ;-------------------temp lcd display ----------------------------
    LCD_DB4     VAR PORTB.4      ; Set port for 4 bits bus
    LCD_DB5     VAR PORTB.5
    LCD_DB6     VAR PORTB.6
    LCD_DB7     VAR PORTB.7
    LCD_RS      VAR PORTB.2      ; Set RS bit port
    LCD_E       VAR PORTB.1      ; Set Enable bit port
    LCD_Lines     CON 2          ; # of Lines on LCD,  1 or 2 (Note: use 2 for 4 lines)
    LCD_DATAUS    CON 50         ; Data delay time in us 
    LCD_COMMANDUS CON 2000       ; Command delay time in us 
    INCLUDE "LCD_AnyPin.pbp"     ; Must go after LCD initialization 
    Pause 500: LCDOUT $FE,1: pause 250   
    LCDOUT $FE,$80,"Display test OK"
    ;------------------------lcd-------------------------------------- 
    
    Goto main 
    
    Main:
        hpwm 1,127,40000        ; Send burst, Ch1, D.Cycle50%, Freq 40Khz
        pauseus 169             ; length of burst.
        CCP1CON = 0             ; Stop sending HPWM
        pauseus 950             ; To prevent Rx from picking up local burst 
        T1CON.0 = 1             ; Start timer1
        for I = 1 to 65           ; Do not send another pulse until 65ms+ later.
            pause 1
        next
    goto main
    
    '---[INT - interrupt handler]-------Got Signal within 60mS
    SignalDetect:
        T1CON.0 = 0             ; Stop timer1
        tTime = 255 * TMR1H + TMR1L
        LCDOUT $FE,$C0,dec tTime
        pause 1000
        LCDOUT $FE,$C0,"                "
        TMR1H = 5535
        TMR1L = 0
    @ INT_RETURN
    
    '---[TMR1 - interrupt handler]------TMR1 Overflow, got no signal
    SignalTimeOut:
        T1CON.0 = 0             ; Stop timer1
        LCDOUT $FE,$C0,"No Signal"
        pause 1000
        LCDOUT $FE,$C0,"         " 
        TMR1H = 5535
        TMR1L = 0      
    @ INT_RETURN
    
    
    end
    Last edited by lilimike; - 24th April 2010 at 14:19.

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


    Did you find this post helpful? Yes | No

    Post

    as timer1H is a 8 bits register ...

    trying to preset it to 5535 will surely show surprising effects ...

    might be:

    timer1h = $15
    timer1l = $9F

    ...

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  4. #4
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    I Thought I knew how to preload the value to get the right timing but you've made me realize that I didn't really know!

    But now I know

    Thank you,

    Mike

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