HI all,
This question comes from a long night of trying to guess the internals on my PIC. While trying to migrate from 16f devices to a 18F1330, I stripped down the code to the most basic part to see if I could understand how to get DT_INTs to run.
Code:
DEFINE OSC 8
clear
ADCON0 = 0
ADCON1 = %00001111 ' Set up ADCON1 no matter what you're doing!!!!!!
T0CON = %10000111 ' Set TMR0 Prescaler Bypassed,
T1CON = %10110001 ' TMR1 ON, 1:1 prescaler 30 mS cycle, 5543 preload
RCON = %00011111 ' NO Priority for interrupts
OSCCON = %01111100
OSCTUNE = %11000010
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
INCLUDE "DT_INTS-18.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
' Variable definition
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
TRISB = %00000000
ledR var PORTB.3 '
ledG var PORTB.4 'on 18F1230
PulseOut var PORTB.7
'**************************************************************************
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR0_INT, _BlankGain, PBP, yes
INT_Handler TMR1_INT, _Transmit, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE TMR0_INT
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
'***************************************************************************
Main:
TOGGLE PulseOut ' heartbeat without the INT
PAUSE 500
goto main
BlankGain: 'TMR0_INT, Green LED
TOGGLE LEDg
TMR0L = 0
TMR0H = 0
@ INT_RETURN
Transmit: 'TMR1_INT , RED led
TOGGLE LEDR
TMR1H = 0
TMR1L = 0
@ INT_RETURN
end
What I found was that I had to be very careful the timing and prescaler or they started to run over each other and it locked up. The issue was that I had to guess at what was happening. In fact, I'm still not sure if I completely understand all I know about it.
Here's the root of the question: How are you watching what is going on inside the code? I have tired on numerous occasions to use MPASM.
I'm sure there is a way, but I have never been able to integrate it and watch while using PBP. I read and article from Chuck Hellebuyck that was suppose to explain it, but I have never got it to work for me.
There is a Simulator from Oshonsoft that is really neat, but strictly Microchip assembly. I have managed to put it to some use, but it is tedious converting PBP to .asm just to see what's going on.
You all can't all be going through this to produce some of the incredible solutions that I see here, are you?
Thanks
Bo
I thought I had it figured out, but I left it running for that last 6 hours and when I came back, all is not well in Gotham. The Green LED is toggling, but the other two are stuck on. Not working as planned, and wondering how to determine where the issue is....
Bookmarks