Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default ReEnterPBP

    where can I get a copy of ReEnterPBP.bas so I can test interupts?

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


    Did you find this post helpful? Yes | No

    Default

    It takes more than ReEnterPBP.bas to do Instant Interrupts.

    The first post in this thread tells where to get ALL the files.
    <br>
    DT

  3. #3
    Join Date
    Jul 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hello dave
    Ok, I found all my files I need however I am using PicBasic Pro Compiler Ver. 2.46. (I'm one of those poor saps that lost his receipt and cannot upgrade.)
    When I compile it works but trying to build using MPLAB I get a masive amount of errors. Here is the code.

    ************************************************** **************
    '* Name : UNTITLED.BAS *
    '* Author : Bill Bubel *
    ' *
    '* Date : 7/31/2009 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    ; Initialize your hardware first.

    INCLUDE "DT_INTS-18.bas" ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts
    DEFINE OSC 4 'Define the Osc to 4 MHz

    asm
    bsf OSCCON, SCS1 ; 1x = Internal Block
    bcf OSCCON, SCS0 ; 00 = Primary Oscillator (20Mhz?)
    bsf OSCCON, IRCF2 ; 111=8000 110=4000 101=2000
    bsf OSCCON, IRCF1 ; 100=1000 011=0500 010=0250
    bcf OSCCON, IRCF0 ; 001=0125 000=0032
    MSTABLE010 btfss OSCCON, IOFS
    bra MSTABLE010 ; wait until Oscillator is stable
    endasm
    LED1 VAR PORTB.2
    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 > 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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wbubel View Post
    Hello dave
    The name's Darrel.

    however I am using PicBasic Pro Compiler Ver. 2.46. (I'm one of those poor saps that lost his receipt and cannot upgrade.)
    It works fine with PBP 2.46

    When I compile it works but trying to build using MPLAB I get a masive amount of errors.
    Then don't use MPLAB if it works when you compile.
    <br>
    DT

  5. #5
    Join Date
    Jul 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    The name's Darrel.


    It works fine with PBP 2.46


    Then don't use MPLAB if it works when you compile.
    <br>
    Sorry Darrel about calling you dave.

    I can compile but not Build. I use a IDC2 with MPLAB to run the PIC 18F1220. I use Microcode studio to write code and compile it to create a .asm file for MPLAB to build.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave here

    in MCS -view-program options-assembler tab. Check the box for using MPASM. The hex will be created when you compile with MCS.

    You do not need to start MPLAB. MCS will start MPASM for you.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jul 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Dave here

    in MCS -view-program options-assembler tab. Check the box for using MPASM. The hex will be created when you compile with MCS.

    You do not need to start MPLAB. MCS will start MPASM for you.
    Dave
    I am using MPASM.

    Code:
     ; Initialize your hardware first.
    
    INCLUDE "DT_INTS-18.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts
    DEFINE OSC 4  'Define the Osc to 4 MHz
         
    asm
                bsf      OSCCON, SCS1        ; 1x = Internal Block
                bcf      OSCCON, SCS0        ; 00 = Primary Oscillator (20Mhz?)
                bsf      OSCCON, IRCF2       ; 111=8000  110=4000  101=2000
                bsf      OSCCON, IRCF1       ; 100=1000  011=0500  010=0250
                bcf      OSCCON, IRCF0       ; 001=0125  000=0032
    MSTABLE010 btfss    OSCCON, IOFS
                bra      MSTABLE010           ; wait until Oscillator is stable
    endasm
    LED1       VAR PORTB.2
    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 > 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
    This code produces errors when I attempt to Build
    Last edited by wbubel; - 31st July 2009 at 22:38.

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 : 6

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