I know it is a bit premature, but here is the custom tailored DT_INTS for the new PIC18FXXK42.
DT_INTS-18_K42.bas
I know it is a bit premature, but here is the custom tailored DT_INTS for the new PIC18FXXK42.
DT_INTS-18_K42.bas
I just realized I didn't finish the job. Kindly disregard the above attachment. There was no way of testing it (of course). Will have corrected version posted soon.
Would love to delete the previous version. Here is the finished one.
Attachment 8507
I don't think that's going to work for the K42 (or the K83).
The memory layout of the SFRs is significantly different in those. The MOVFF instructions can't access the SFR banks... you need to use the new MOVFFL instruction available on those cores.
the latest attachment is not working.
my 2 cents
looks like the auto context saving for low p interrupts needs addressing too.
if its going to fly the vectored isr capability should not be ignored .
not quite sure about the MOVFFL issue
sfrs in access bank should be ok.
the others should respond to the appropriate banksel , I think .
the few pieces of asm code example in the datasheets look fairly conventional in that reguard
Warning I'm not a teacher
The SaveFSR and RestFSR macros along with INT_CREATE_H, INT_CREATE_L, and INT_RETURN all use MOVFF to save the context.
MOVFF can only address the first 4K of ram and the K42 is part of the new 18XV core devices that can address up to 16K of ram.
In these new devices the SFR registers have been moved into the upper banks past where the MOVFF instruction can address.
The new MOVFFL instruction has to be used in its place to address the full 14-bit ram space.
I haven't used one of these yet but the whole context saving mechanism of dt-ints may not be needed with these.
The new core includes a two-level deep context stack which saves the STATUS, WREG, BSR, FSR0/1/2, PRODL/PRODH and
PCLATH/U registers automatically for you into the shadow register memory located in bank 56.
I am trying to use DT_INTS FOR K42 with a PIC18F27K42. I am familiar with using DT_INTS-18. Works perfectly with other PICs. However, I am receiving several errors when compiling with DT_INTS FOR K42. My PBP version is PBPX3.1.34. MPLABX is V5.30. The PBP test code simply configures comparator 1 and lights indicator LEDs to indicate if the voltage is above or below the reference voltage, and when the Comparator interrupt flag has been set or cleared. The test code works without the inclusion of DT_INTS-18K42b.
However, I receive several compile errors when I add the following code to generate an interrupt on comparator 1:
;------------------ DT Instant Interrupts ------------------------
wsave1 var byte $A0 system ;location for W if in bank0
wsave2 var byte $120 system ;location for W if in bank0
wsave3 var byte $1A0 system ;location for W if in bank0
INCLUDE "DT_INTS-18_K42b.bas" ; Base Interrupt System
INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler C1_INT, _CMP_1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
INT_ENABLE C1_INT ; Comparator 1 interrupt
ENDASM
The interrupt handler is a simple counter. It serves no purpose other than testing.
;------------------[CMP1 - interrupt handler]------------------------
CMP_1: ;Comparator triggered
Ticks1 = Ticks1 + 1 ;Increment counter
@ INT_RETURN
When compiled, I receive three error messages "Found label after Column 1. (Save FSR)". Also the error messages: Illegal Nesting (ENDM); Expected (END); Expected (ENDM).
Based on my read of the #Defines in DT_INTS-18_K42b.bas, and the PIC18F27K42 datasheet Summary of Registers for Interrupts, I think DT_INTS-18_K42b.bas should work with this PIC.
Any suggestions for solving the problem will be appreciated.
Dan
The DT_INTS-18_K42b.bas file from post #9 won't work.
Thanks for the response. Do you know if the problem is with the DT_INTS-18_K2b file not being mapped properly to the PIC18F27K42 interrupt register, or is it that the PIC18F27K42 will not work with DT's Instant Interrupts? If it is a matter of correcting errors, I found the "How to make custom DT's Instant Interrupts" and can try an make the necessary edits.
It's more than just a simple interrupt register issue. The asm instructions are wrong for the K42.
See posts #4 and #6.
Looks like crafting a working DT's Instant Interrupts for the PIC18F27K42 is well beyond my skill set. It may be time for me to learn to write ISRs using assembly language. In addition to the PBP3 reference manual discussion of Assembly Interrupts for PIC 18 Devices, can anyone suggest a good reference for someone who is not familiar with assembly language coding?
I have also been using c for long time so far; I have been able to convert some Arduino libraries, too.
The thing is, as mentioned earlier, moving from one compiler to another in c is much easier using the same code.
However, dealing with the registers manually is not as easy as PBP;
PBP is in my heart;
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Microchip has online training that covers ANSI C, MPLABX, MCC, a long list of useful projects, and more:
http://microchipdeveloper.com/training-self:start
I have learned much from their training. I highly recommend it for those wishing to dabble in the mystical realm of MPLABX.
Are there any updates regarding the K42 devices and DT-INTS ?
Ioannis
If you're feeling adventurous you could try the attached.
It's a modified version of the DT_INTS-18_K42b.bas code from post #9 with the context save stuff removed (now done in hdw) and the MOVFF instructions replaced with MOVFFL, which is required in the K42 and K83 since the SFR's are outside the 2K boundary for the MOVFF instruction.
It's completely untested...
Bookmarks