where can I get a copy of ReEnterPBP.bas so I can test interupts?
where can I get a copy of ReEnterPBP.bas so I can test interupts?
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
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
The name's Darrel.
It works fine with PBP 2.46however I am using PicBasic Pro Compiler Ver. 2.46. (I'm one of those poor saps that lost his receipt and cannot upgrade.)
Then don't use MPLAB if it works when you compile.When I compile it works but trying to build using MPLAB I get a masive amount of errors.
<br>
DT
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.
Dave
I am using MPASM.
This code produces errors when I attempt to BuildCode:; 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
Last edited by wbubel; - 31st July 2009 at 22:38.
Bookmarks