Dt_ints-18 18f4550 usb_int usb bootloader
I realize i'm likely behind about 2 years on this one.. i've been trying to modify Mister E / Darrel's USBDEMO code so that it works with my existing setup (a vb app that aquires 8 bit a/d result from the chip over usb cdc com port and also relays it to a serially connected 16F767.
Can anyone make comment or point me to the appropriate thread discussing the DT INTS & Microchip bootloader on an 18F4550. I can't seem to get it going.. i'm doing a cdc device that otherwise works fine with the standard "usbservice" everywhere method.. so I know I don't have a hardware issue... basically what occurs with the new program is nothing. and stuff freezes too (Hyperterminal, my application) without getting any data (or so it seems).
The device i'm building (i'm not showing you it's a total hackjob - that works) is "self powered" (i think) It runs off either a Max756 or a 7805C output or USB power, which on my hackjob of a board, is selected with jumpers. I've been attempting to detect the state of the usb connection, with limited success.. which currently involves 1x 100k and 1x 10k resistors to ground and USBV+ (5v from the usb cable) meeting in the middle at PORTB.0 which i've named "USBCONNECTED".
Do I need the INTERRUPT_ORG defines, something else? I'd also like to implement a "SLEEP" command when the cable isnt connected, if anyone can tell me how to properly detect the cable and connection as this is a self powered device which will run off battery / solar power. I've done some research and have a working device but I think my newbish methods for doing things is limiting the speed and using more power than it needs to (logic draws about 60-120mA running full tilt while not connected to USB (no sleep)
Basically I suppose my question is what should I do in addition to this code in order to use Darrels Interrupt system and use the Microchip Bootloader.
The Instant Interrupts modified code, sorry for the long post:
Changing direction after INT
I'm trying to understand how to return to a specific place when coming out of a INT.
Specifically, when I receive a command serially and trip the RX_INT, I need to abort the current operation in the main body of the program and restart with the newly commanded mode.
I have looked at DT_INTS and other advise on interrupts, and still don't understand what I would need to change to get this to happen.
The code works otherwise and gathers the command from the serial line, its just that I have to wait for the current operation to complete for it to be recognized and acted upon.
The main code is driving patterns on 8 LEDS with SPWM_INT and it takes 10 or 20 seconds for it to get around to the place where it looks at the new mode. This also applies when I change the mode with a switch input. I have to wait until the operation is finished to get to the part where I look for the input.
I don't believe that I can just mess with the RetAddr variable in DT_INTS and have that work without other steps. If I have a GOTO in the ISR, then I would likely corrupt the RETURN. I could just sprinkle switch and comm checks all over the place looking for flags, but that seems mediocre. Any advise?
Thanks
Mark
How long does it take to process disable command?
Hi DT,
When @ INT_DISABLE TMR0_INT command is used @4Mhz 16F628A, can you estimate how long does it take to process it and eventually disable it?
uS?
Thanks.
PIC16F616, Interrupt on PORTA change
Not sure if this have been covered, but however. I'm actually working with a PIC16F616, there's no interrupt on PORTB change on this one, but Interrupt on PORTA change, great Microchip ;)
From what i see, it is not included in DT_INTS-14, so here's one method to do so...
Open DT_INTS-14, and add the sections in Red
Code:
ASM
#define INT_INT INTCON,INTF ;-- INT External Interrupt
#define RBC_INT INTCON,RBIF ;-- RB Port Change Interrupt
#define RAC_INT INTCON,RAIF ;-- RA Port Change Interrupt
#define TMR0_INT INTCON,T0IF ;-- TMR0 Overflow Interrupt 16F
#define TMR1_INT PIR1,TMR1IF ;-- TMR1 Overflow Interrupt
#define TMR2_INT PIR1,TMR2IF ;-- TMR2 to PR2 Match Interrupt
#define TX_INT PIR1,TXIF ;-- USART Transmit Interrupt
#define RX_INT PIR1,RCIF ;-- USART Receive Interrupt
#define CMP_INT PIR2,CMIF ;-- Comparator Interrupt
#define EE_INT PIR2,EEIF ;-- EEPROM/FLASH Write Operation Interrupt
#define BUS_INT PIR2,BCLIF ;-- Bus Collision Interrupt
#define PSP_INT PIR1,PSPIF ;-- Parallel Slave Port Read/Write Interrupt
#define AD_INT PIR1,ADIF ;-- A/D Converter Interrupt
#define SSP_INT PIR1,SSPIF ;-- Master Synchronous Serial Port Interrupt
#define CCP1_INT PIR1,CCP1IF ;-- CCP1 Interrupt
#define CCP2_INT PIR2,CCP2IF ;-- CCP2 Interrupt
ENDASM
asm
INT_Source macro IFR, IFB, IER, IEB
if ((IflagReg == IFR) && (IflagBit == IFB))
list
INT_Flag_Reg = IFR
INT_Flag_Bit = IFB
INT_Enable_Reg = IER
INT_Enable_Bit = IEB
Found = YES
endif
; nolist
endm
endasm
asm
;-------------------------------------------------------------------------------
GetIntInfo macro IflagReg, IflagBit
Found = NO
; nolist
ifdef INTF ;----{ INT External Interrupt }----------------[INTCON, INTF]---
INT_Source INTCON, INTF, INTCON, INTE
endif
ifdef RBIF ;----{ RB Port Change Interrupt }--------------[INTCON, RBIF]---
INT_Source INTCON, RBIF, INTCON, RBIE
endif
ifdef RAIF ;----{ RA Port Change Interrupt }--------------[INTCON, RAIF]---
INT_Source INTCON, RAIF, INTCON, RAIE
endif
ifdef T0IF ;----{ TMR0 Overflow Interrupt }-------------[INTCON, TMR0IF]---
INT_Source INTCON, T0IF, INTCON, T0IE
endif
ifdef TMR1IF ;----{ TMR1 Overflow Interrupt }---------------[PIR1, TMR1IF]---
INT_Source PIR1, TMR1IF, PIE1, TMR1IE
endif
ifdef TMR2IF ;----{ TMR2 to PR2 Match Interrupt }-----------[PIR1, TMR2IF]---
INT_Source PIR1, TMR2IF, PIE1, TMR2IE
endif
ifdef TXIF ;----{ USART Transmit Interrupt }----------------[PIR1, TXIF]---
INT_Source PIR1, TXIF, PIE1, TXIE
endif
ifdef RCIF ;----{ USART Receive Interrupt }------------------[PIR1 RCIF]---
INT_Source PIR1, RCIF, PIE1, RCIE
endif
ifdef CMIF ;----{ Comparator Interrupt }--------------------[PIR2, CMIF]---
ifdef PIR2
INT_Source PIR2, CMIF, PIE2, CMIE
else
INT_Source PIR1, CMIF, PIE1, CMIE
endif
endif
ifdef EEIF ;---{ EEPROM/FLASH Write Operation Interrupt }---[PIR2, EEIF]---
ifdef PIR2
INT_Source PIR2, EEIF, PIE2, EEIE
else
INT_Source PIR1, EEIF, PIE1, EEIE
endif
endif
ifdef BCLIF ;----{ Bus Collision Interrupt }----------------[PIR2, BCLIF]---
INT_Source PIR2, BCLIF, PIE2, BCLIE
endif
ifdef PSPIF ;--{ Parallel Slave Port Read/Write Interrupt }--[PIR1, PSPIF]--
INT_Source PIR1, PSPIF, PIE1, PSPIE
endif
ifdef ADIF ;----{ A/D Converter Interrupt }------------------[PIR1, ADIF]---
INT_Source PIR1, ADIF, PIE1, ADIE
endif
ifdef SSPIF ;----{ Master Synchronous Serial Port Interrupt }--[PIR1, SSPIF]-
INT_Source PIR1, SSPIF, PIE1, SSPIE
endif
ifdef CCP1IF ;----{ CCP1 Interrupt }-------------------------[PIR1, CCP1IF]---
INT_Source PIR1, CCP1IF, PIE1, CCP1IE
endif
ifdef CCP2IF ;----{ CCP2 Interrupt Flag }--------------------[PIR2, CCP2IF]---
INT_Source PIR2, CCP2IF, PIE2, CCP2IE
endif
list
endm
list
ENDASM
Sure enough there's some other PIC with interrupt on PORTA change, I just never came across one... or maybe... but never used that feature yet ;)