Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    I finally had a chance to try DT_Ints-18, and it works (of course) as advertised. I can't thank you enough for working on this and finishing it just as I had a pressing need.

    Keep up the good work!

    Can I ask for HI2CREAD and HI2CWRITE next? Real FUNCTIONS?
    Charles Linquist

  2. #2
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130


    Did you find this post helpful? Yes | No

    Default Hi Darrel

    That was fast!

    My errors are as follows,
    Warning[230]c:\pbp\18f4550inc 20:_config has been deprecated for PIC18 devices. Use directive CONFIG. (this is listed five times, then,)
    Error[128]c:\progra~1\Mecani~1\example2.asm 1150:missing arguement(s)
    Error[113]c:\ "" 602: Symbol not previously defined (INTFLAGREG)
    603: Symbol not previously defined (INTFLAGBIT)
    218: " (INTFLAGREG)
    218: " (INTFLAGBIT)
    656: ERROR (INTERRUPT SOURCE (INTFLAGREG,INTFLAGBIT) NOT FOUND
    713: ERRORINT_ENABLE - Priority State Not Found)

    Thanks, I'm dying to try this out!

    Jerry Gavin

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


    Did you find this post helpful? Yes | No

    Default

    about the CONFIG warning error look at the FAQ
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    Now be sure all files are in the same directory (source code, include and so on)

    Still having problem? post your whole code here.

    HTH
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis
    Can I ask for HI2CREAD and HI2CWRITE next? Real FUNCTIONS?
    what you mean by 'real function' ? unless using Macro and INCLUDE files and as far as i'm aware of, we can't add in the existing function list... i would be so much handy.

    Darrel... Yet another Plug-In application
    Steve

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

  5. #5
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130


    Did you find this post helpful? Yes | No

    Smile Problem solved!

    When you have eliminated all possible problems, the only one left, no matter how improbable must be the solution, to paraphrase Sherlock Holmes. I noticed that two of the files that I downloaded were showing up as smaller than the file sizes listed on Darrel's site. I deleted them and downloaded again, and everything compiled perfectly the first time! Works Great! I had just received a few 18F4550s to play with so Darrel's timing was perfect.

    Also, thanks to Steve for the note regarding the Config problem.

    Thanks to all,

    Jerry Gavin

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Jerry,

    Great, I'm so glad you found it. Never would have figured that out from here.

    Charles,

    You're welcome,

    I think the HI2C, and HI2CSLAVE should be pretty easy now with DT_INTS. As well as HSPI and HSPISLAVE, PSPSLAVE, SSPWM, Multi-SSPWM, PWPS, Multi-PWPS, etc. etc. etc.

    However, in order to facilitate some of those types of commands, I think the next step is a universal FIFO (First In First Out) buffer structure. Already have it working, but it looks real ugly right now.

    As for Functions, I think Steve's right. Until we can gain control over the compiler, or the IDE, or maybe create a Pre-compiler, Functions will remain on the PBP wish list.

    DT

    P.S. My "Timing" is still not perfect though, since I've been totally sidetracked from the Elapsed Timer/Oscillator accracy problem.
    <br>

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default

    This is just so cool, this stuff is exactly what I needed to service USB without having to figure out how much to sprinkle within the code.

    Can't wait to try this after dinner.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  8. #8
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    You said "If you increase the frequency of the timer Overflows, either by reducing the prescaler, or by re-loading the timer on each interrupt, or both, you can control the duty cycle within the interrupt handler."

    When I look at your program, I am completely lost. Can you tell me exactly what variable(s) I have to changed to get the LED blink faster or slower?

    Thanks,

    Chris

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Advanced Blinky Light (fader)

    Chris,

    The prescaler can be changed with T1CON.
    $31 = 1:8
    $21 = 1:4
    $11 = 1:2
    $01 = 1:1

    And the Timer is reloaded by putting values in TMR1H:TMR1L.

    So first, decide what frequency you need, I'll go with 100hz.

    Then, go to this thread...
    Testing Forms [TimerCalc] Working I think?
    http://www.picbasic.co.uk/forum/showthread.php?t=2031

    Enter the OSC value you are using, say 20mhz.
    I'll also go with 1:1 prescaler, enter that. (ok, it's already there)
    Then enter 100 in the Freq field at the bottom.

    Now you can see that it will take a total of 50,000 counts (ticks) to achieve 100hz.

    Decide what resolution you want for the Duty-Cycle. ummm, 8-bit (256).

    Now you just calculate the ON count from that with...
    50000*DutyCycle/256 which is the same thing as...
    50000*/DutyCycle in PBP
    and the OFF count is 50000 - ONcount

    Ok, so let's put that into the Blinky Light example


    Code:
    
    ; Initialize your hardware first.
    
    
    INCLUDE &quot;DT_INTS-18.bas&quot;     ' Base Interrupt System
    INCLUDE &quot;ReEnterPBP-18.bas&quot;     ' Include if using PBP interrupts
    
    
    LED1       VAR PORTB.1
    DutyCycle  VAR BYTE
    
    
    TotalCount CON 50000
    ONcount    VAR WORD
    OFFcount   VAR WORD
    
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    
    T1CON = $00                ; Prescaler=1:1, TMR OFF
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    
    
    Main:
        FOR DutyCycle = 0 TO 255           ; Ramp up
            GOSUB  SetDutyCycle
            PAUSE  5
        NEXT DutyCycle
    
    
        FOR DutyCycle = 254 TO 1 STEP -1   ; Ramp down
            GOSUB  SetDutyCycle
            PAUSE  5
        NEXT DutyCycle
    GOTO Main
    
    
    
    
    SetDutyCycle:
        ONcount = TotalCount*/DutyCycle
        OFFcount = TotalCount - ONcount
        IF DutyCycle = 0 THEN
            T1CON.0 = 0    ; turn off timer
            LOW  LED1      ; idle LOW
        ELSE
            T1CON.0 = 1    ; timer on if DutyCycle &gt; 0
        ENDIF 
    RETURN
    
    
    DISABLE DEBUG
    '---[TMR1 - interrupt handler]------------------------------------------------
    @Timer1=TMR1L             ; map timer registers to a word variable
    Timer1 VAR WORD EXT
    
    
    ToggleLED1:
        IF LED1 THEN
            LOW LED1
            T1CON.0 = 0         ; stop the timer
            Timer1  = OFFcount  ; Load OFF count
            T1CON.0 = 1         ; start timer
        ELSE
            HIGH LED1
            T1CON.0 = 0         ; stop the timer
            Timer1  = ONcount   ; Load ON count
            T1CON.0 = 1         ; start timer
        ENDIF
    @ INT_RETURN
    ENABLE DEBUG
    
    Last edited by mackrackit; - 1st February 2012 at 10:35. Reason: HTML
    DT

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 22:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 21:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 21:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 07:32
  5. Replies: 1
    Last Post: - 1st November 2006, 04:11

Members who have read this thread : 5

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

Tags for this Thread

Posting Permissions

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