Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Could it simply be that a lot of the information on the net for PIC newbies is for projects using the 16C84 and for simple programmers that program them.

    I certainly started with the 16C84 but I wouldnt use one now. For small stuff I use the 16F628 on my existing projects and 16F88 on the new projects because of the bootloader.

    Larger projects are using the 16F877 or 18F452 again with bootloaders.

    Somewhere I have some 508's including a couple of JW's that were bought and never used along with a UV eraser that has never even ben plugged in and probably never will now !!!!

    As far as I am concerned, Flash + Bootloader + PBP + MCS rules
    Keith

    www.diyha.co.uk
    www.kat5.tv

  2. #2
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by keithdoxey
    As far as I am concerned, Flash + Bootloader + PBP + MCS rules
    Flash + Bootloader + PBP + MCS + Instant Interrupts rules. <img src="images/smilies/smile.gif" alt="" title="smile" class="inlineimg" border="0">

  3. #3
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dhouston
    Flash + Bootloader + PBP + MCS + Instant Interrupts rules. <img src="images/smilies/smile.gif" alt="" title="smile" class="inlineimg" border="0">
    I stand corrected
    Keith

    www.diyha.co.uk
    www.kat5.tv

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


    Did you find this post helpful? Yes | No

    Default

    To: Demon and mister_e,

    Hey, did you guys ever figure out the USB with DT_INTs approach.

    I was thinking about trying a USB project, and wondered if you 2 ever got it working?
    <br>
    Last edited by Demon; - 4th October 2016 at 18:44.
    DT

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Unhappy

    Quote Originally Posted by Darrel Taylor View Post
    To: Demon and mister_e,

    Hey, did you guys ever figure out the USB with DT_INTs approach.

    I was thinking about trying a USB project, and wondered if you 2 ever got it working?
    <br>
    Well, i hate to say that Darrel but something goes bad when using instant interrupt and USB. Maybe some PBP variable need to be saved or something like that.

    Bellow is a short and sweet working example using ON INTERRUPT to do the USBSERVICE each 100uSec.

    OK it doesn't do anything else than sitting there and spin but, it keeps the connection alive without any Windows Warning. Once this solve, it should fix USBOUT and USBIN... or help to

    It use a PIC18F4550 and a 4MHZ crystal OSC.
    Code:
    asm
        __CONFIG    _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L  
                                ;              ;                      ; USB clock source comes from the 96 MHz PLL divided by 2
                                ;              ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
                                ; No prescale (4 MHz oscillator input drives PLL directly)
    
    
        __CONFIG    _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H 
                                ;                  ;               ; Oscillator Switchover mode disabled
                                ;                  ; Fail-Safe Clock Monitor disabled
                                ; XT oscillator, PLL enabled, XT used by USB
        __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
        __CONFIG    _CONFIG2H, _WDT_OFF_2H 
        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L 
    endasm
    DEFINE OSC 48          
    
    PORTB   =   0
    TRISB.0 =   0
    
    LED0    VAR PORTB.0
    TMR0IF  VAR INTCON.2
    TMR0ON  VAR T0CON.7
    
    INTCON  =   %10100000       ' Enable global and TMR0 interrupts
    T0CON   =   %10000000       ' TMR0, CLK internal, prescaler 1:2, T0ON
    
    UCFG    var byte EXT        ' include UCFG register... Yeah Melabs didn't :o(
    
    Reload      con 65000       ' ~100 uSec
    ucfg    =   %00010100       ' enable internal USB pull-up, Full speed USB
    
    goto SkipMacro
        asm 
    Reload_TMR0 macro
        BCF     _TMR0ON         ; stop timer
        MOVE?CW _Reload,TMR0L   ; reload
        BCF     _TMR0IF         ; clear overflow flag
        BSF     _TMR0ON         ; start timer
        ENDM
        endasm
    
    SkipMacro:
        pause 500               ' Settle delay
        usbinit                 ' initialise USB...
    @   Reload_TMR0             ; Reload timer0
        ON INTERRUPT GOTO DoUSBService
    
    Start: 
        goto start              ' Spin 'till you die!
    
    DISABLE
    DoUSBService:
        toggle LED0             ' toggle LED each time 
        usbservice              ' keep connection alive
    @   Reload_TMR0             ; reload timer
        RESUME                  ' getout of here
    ENABLE
    So nothing complicated... just spinning and keep USB connection alive.

    NOW, if i use the DT interrupt, IT SHOULD looks like this
    Code:
    asm
        __CONFIG    _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L  
                                ;              ;                      ; USB clock source comes from the 96 MHz PLL divided by 2
                                ;              ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
                                ; No prescale (4 MHz oscillator input drives PLL directly)
    
    
        __CONFIG    _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H 
                                ;                  ;               ; Oscillator Switchover mode disabled
                                ;                  ; Fail-Safe Clock Monitor disabled
                                ; XT oscillator, PLL enabled, XT used by USB
        __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
        __CONFIG    _CONFIG2H, _WDT_OFF_2H 
        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L 
    endasm
    DEFINE OSC 48          
    PORTB   =   0
    TRISB.0 =   0
    
    LED0    VAR PORTB.0
    TMR0IF  VAR INTCON.2
    TMR0ON  VAR T0CON.7
    
    INTCON  =   %10100000       ' Enable global and TMR0 interrupts
    T0CON   =   %10000000       ' TMR0, CLK internal, prescaler 1:2, T0ON
    
    UCFG    var byte EXT        ' include UCFG register... Yeah Melabs didn't :o(
    
    Reload      con 65000       ' ~100 uSec
    ucfg    =   %00010100       ' enable internal USB pull-up, Full speed USB
    
    INCLUDE "DT_INTS-18.bas"    ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts
    
    goto skipmacro
    
        ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    TMR0_INT,  _DoUSBService,   PBP,  no
        endm
        INT_CREATE               ; Creates the interrupt processor
    
    Reload_TMR0 macro
        BCF     _TMR0ON         ; stop timer
        MOVE?CW _Reload,TMR0L   ; reload
        BCF     _TMR0IF         ; clear overflow flag
        BSF     _TMR0ON         ; start timer
        ENDM
        endasm
    
    SkipMacro:
        pause 500
        usbinit ' initialise USB...
    @   Reload_TMR0
    @   INT_ENABLE  TMR0_INT
    
    Start: 
        goto start        
    
    DoUSBService:
        toggle led0
        usbservice
    @   Reload_TMR0
    @   INT_RETURN
    Right or i screw something? Anyways ON both, the LED work as expected (so i shouldn't be too wrong) but, the second lost the USB connection really soon... and yeah you have to reboot or it will reboot for you if you disconnect
    the USB plug. It's getting boring

    i attach everything i have in my C:\PBP_PROG\USBDemo folder, including a compiled VB utility to monitor if the device is Connected or Not when using EasyHID default VendorID and ProductID

    <img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1300&stc=1&d=116748409 1">


    So for now, i still use the On Interrupt... Before i read and understand the whole Jan Axelson book, and build my own USB macros, i may need much spare time... oh yeah it's more than a RS-232 and there's a lot of improvements and adds to do with PBP.

    Now the weird stuff... Melabs didn't include the 'interesting' registers like UCFG, UIR,UIE,UEIR,UEIE and probably others... bah xxx VAR BYTE EXT fix it for now and if needed.

    To be honest, i didn't search really hard to find the problem source... getting lazy i guess :-)
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by Demon; - 4th October 2016 at 18:44.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default That should do it.

    Wow, it seems like that should work?

    That sure gives me a starting point, (good one)

    And since you're also in such a good "moon"

    I'll take a look at ...
    http://www.picbasic.co.uk/forum/showthread.php?t=5418
    Too
    <br>
    DT

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Moon or mood.... that's the question



    Well maybe i should say MOOD?
    Your Canadian to English dictionnary is still good

    Enjoy!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 06:32
  5. Replies: 1
    Last Post: - 1st November 2006, 03: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