Instant Interrupts - Revisited - Page 4
+ Reply to Thread
Page 4 of 20 FirstFirst 1234567814 ... LastLast
Results 121 to 160 of 791
  1. #121
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Hi willem,

    It's a little more than the duplicate variables. They also both want exclusive use of the interrupt vector, and they handle the interrupts in a different way too.

    I've thought about writing a version for DT_INTS, but just haven't had the time. It's quite doable, but it definately takes some ASM.

    Sorry for the bad news,
    DT

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

    Cool Software PWM for DT_INTS-xx

    Ok Willem,

    Well, I decided to forget about the things I should have done this weekend, and went ahead and re-wrote the SPWM program to work with the Instant Interrupt system.

    I've added a few things, and it works a little different this time around. So, be sure to look close at the example.

    It'll work with either the 18F or 14-bit versions, even though I only put it in the DT_INTS-14 section for now.

    SPWM_INT
    http://www.darreltaylor.com/DT_INTS-14/SPWM.html

    Enjoy,
    DT

  3. #123
    Baddzso's Avatar
    Baddzso Guest

    Default EUSART int

    hi all! hi Darrel!
    I have a question: with these int handler routines can i use hserin with interrupt? because i think the on interrupt command too slow, i have to wait about 1 ms after first char to the pic jump to int routine and receive other chars with hserin.
    many thanks!

    pic: 16f690, intosc, ~7,3728MHz

    (I don't have time to read everything, sorry if this question are answered...)
    Attached Files Attached Files
    Last edited by Baddzso; - 2nd October 2006 at 23:17.

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

    Default

    Well,

    With the example given, Sure!

    But with 16F's, if it gets more complicated, you might have problems. The problem is that when you have more than 1 interrupt source, the HSERIN will stop the others from happening while it waits for the data to come in. But if you only intend to use the one interrupt from the USART. No Problem.

    If you were using an 18F with multiple INT sources, then the HSERIN could be in a Low Priority Interrupt without any problems at all.
    <br>
    DT

  5. #125
    willem's Avatar
    willem Guest

    Thumbs up

    Hi Darrel,

    Great you decide to spent some weekend time on it! I'll hope you did enjoy your weekend anyway..
    I will check out the new Multi_SPWM version ASAP and post the results.
    Tnx a lot for your kind help.

    Regards,
    Willem

  6. #126
    Baddzso's Avatar
    Baddzso Guest

    Smile

    Thank you for fast reply!
    And YES, YES, YES!!!
    It works! You are my rescuer!
    Thank You!
    Last edited by Baddzso; - 3rd October 2006 at 11:46.

  7. #127
    willem's Avatar
    willem Guest

    Smile Software PWM for DT_INTS-xx

    Dear Darrel,

    I just would like to let you know the combined DT_INTS-14 and SPWM_INT working fine!!

    I control 5 Hi power LEDís Using 5 PWM signals (100Herz, 200 step), LED selecting is done by 3 address lines and the actual control by a pulsed STEP and a UP/DOWN level input.

    STEP is causing the INT external interrupt doing the actual PWM change (controlling DutyVar1 to DutyVar5)

    Whenever I change a PWM value, itís stored as the new default in EEprom (using WRITE command with DISABLE INTERRUPT before and ENABLE INTERRUPT after, working OK too).

    If you like to have more info on both hardware and software, let me know.
    Thank you for your help!

    Regards,
    Willem

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

    Thumbs up

    Excellent!

    That's great Willem. I'd love to see what you've done with it. Maybe you could post it in the "Code Examples" forum. Better as a new thread. This thread is getting so big it would only get lost in the mess.

    Or I can put it on the website, as an example for SPWM_INT if you'd like. Hopefully, with a picture of the project too?
    DT

  9. #129
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    136

    Question

    Hello Darrel,
    Is there any way i can implement you instant interrupt routines on PICs which do not have the TMR0 interrupt ( like the PIC16C54A) ???

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

    Default

    No,

    The 16C54A doesn't have any interrupts.

    They only have 512 words of program space, 25 bytes of RAM, and a 2-level hardware stack.

    At 4 dollars each, I can't imagine why anyone would ever use them.
    <br>
    DT

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

    Default

    Same observation for 16F84(a)
    Steve

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

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

    Default

    Yeah, no kidding.

    Everyone uses those F84's for examples, probably because there's nothing else to confuse you like, USARTs, CCP's, A/D's or SSP's. But man, who'd actually want to use one.

    I've had 2 of them for a couple years. But they're still Virgins. Never been plugged into anything.
    <br>
    DT

  13. #133
    Join Date
    Feb 2003
    Posts
    432

    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

  14. #134
    Join Date
    Dec 2005
    Posts
    1,073

    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">

  15. #135
    Join Date
    Feb 2003
    Posts
    432

    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

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

    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

  17. #137
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default

    Quote Originally Posted by Darrel Taylor View Post
    So far I've shown one interrupt source being used at a time, but as I said in the first post, you can easily service Multiple Interrupt Sources. &nbsp; So what if we wanted to join the previous 3 examples into one program. &nbsp; NOT a problem!

    To add more interrupt "Handlers", simply add them to the INT_LIST, and create a subroutine for them.

    Since both the Blinky Light, and Elapsed Timer used TMR1, lets move the Blinky Light over to TMR0. Elapsed will still use TMR1.
    Code:
    <font color="#000000"><b>LED1   </b><font color="#008000"><b>VAR  </b></font><b>PORTD</b>.<b>0
    LED2   </b><font color="#008000"><b>VAR  </b></font><b>PORTD</b>.<b>1
    
    </b><font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">&quot;DT_INTS-14.bas&quot;     </font><font color="#0000FF"><b><i>' Base Interrupt System
    </i></b></font><font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">&quot;ReEnterPBP.bas&quot;     </font><font color="#0000FF"><b><i>' Include if using PBP interrupts
    </i></b></font><font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">&quot;Elapsed_INT.bas&quot;    </font><font color="#0000FF"><b><i>' Elapsed Timer Routines
    
    </i></b></font><font color="#008000"><b>ASM
    </b></font><font color="#000080">INT_LIST  macro    </font><font color="#0000FF"><b><i>; IntSource,        Label,  Type, ResetFlag?
            </i></b></font><font color="#000080">INT_Handler    INT_INT,  _ToggleLED1,   PBP,  yes
            INT_Handler   TMR0_INT,  _ToggleLED2,   PBP,  yes
            INT_Handler   TMR1_INT,  _ClockCount,   PBP,  yes
        endm
        INT_CREATE               </font><font color="#0000FF"><b><i>; Creates the interrupt processor
    
        </i></b></font><font color="#000080">INT_ENABLE   INT_INT     </font><font color="#0000FF"><b><i>; enable external (INT) interrupts
        </i></b></font><font color="#000080">INT_ENABLE  TMR0_INT     </font><font color="#0000FF"><b><i>; enable Timer 0 interrupts
        </i></b></font><font color="#000080">INT_ENABLE  TMR1_INT     </font><font color="#0000FF"><b><i>; Enable Timer 1 Interrupts  
    </i></b></font><font color="#008000"><b>ENDASM
    
    </b></font><b>OPTION_REG </b>= <b>OPTION_REG </b>&amp; <b>$80 </b>| <b>1  </b><font color="#0000FF"><b><i>; Set TMR0 Prescaler to 256, leave RBPU alone
    </i></b></font><font color="#008000"><b>GOSUB </b></font><b>ResetTime              </b><font color="#0000FF"><b><i>' Reset Time to  0d-00:00:00.00
    </i></b></font><font color="#008000"><b>GOSUB </b></font><b>StartTimer             </b><font color="#0000FF"><b><i>' Start the Elapsed Timer
    
    </i></b></font><b>Main</b>:
        <font color="#008000"><b>IF </b></font><b>SecondsChanged </b>= <b>1 </b><font color="#008000"><b>THEN  
           </b></font><b>SecondsChanged </b>= <b>0
           </b><font color="#008000"><b>LCDOUT </b></font><b>$FE</b>,<b>$C0</b>, <font color="#008000"><b>DEC </b></font><b>Days</b>,<font color="#FF0000">&quot;d-&quot;</font>,<font color="#008000"><b>DEC2 </b></font><b>Hours</b>,<font color="#FF0000">&quot;:&quot;</font>,<font color="#008000"><b>DEC2 </b></font><b>Minutes</b>,<font color="#FF0000">&quot;:&quot;</font>,<font color="#008000"><b>DEC2 </b></font><b>Seconds
        </b><font color="#008000"><b>ENDIF
    GOTO </b></font><b>Main
    
    </b><font color="#0000FF"><b><i>'---[INT - interrupt handler]---------------------------------------------------
    </i></b></font><b>ToggleLED1</b>:
         <font color="#008000"><b>TOGGLE </b></font><b>LED1
    </b><font color="#000080">@ INT_RETURN
    
    </font><font color="#0000FF"><b><i>'---[TMR0 - interrupt handler]-------------------------------(Blinky Light)------
    </i></b></font><b>T0Count  </b><font color="#008000"><b>VAR WORD
    </b></font><b>ToggleLED2</b>:
        <b>T0Count </b>= <b>T0Count </b>+ <b>1
        </b><font color="#008000"><b>IF </b></font><b>T0Count </b>= <b>512 </b><font color="#008000"><b>THEN </b></font><b>T0Count </b>= <b>0 </b>: <font color="#008000"><b>TOGGLE </b></font><b>LED2
    </b><font color="#000080">@ INT_RETURN
    </font>
    <font size=-2>Code Size = 711 Words</font>

    Now we have all three interrupt sources working together in the same program.
    LED1 responds to the external INT
    LED2 flashes, timed by TMR0
    and, the elapsed timer is maintained via TMR1
    And, all of this is happening behind the scenes of your normal PBP program.
    I test for 16f877a and it's work.
    But for the 18f88 i got the message : Symbol not previously defined (T0IF)
    and not compile.Why;

  18. #138
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by savnik View Post
    I test for 16f877a and it's work.
    But for the 18f88 i got the message : Symbol not previously defined (T0IF)
    and not compile.Why;
    That would be a good trick....compiling for an 18F88. I can't seem to find it on the Microchip website.

    Try TMR0IF (a zero after TMR). Or you don't have an up-to-date version of PBP.

    Previous Release: 2.45

    * Adds support for PIC12F508, 509, 683, PIC16F505, 684, 688, 716, 737, 747, 767, 777, 87, 88, PIC18F2331, 2431, 2515, 2525, 2585, 2610, 2620, 2680, 4331, 4431, 4515, 4525, 4585, 4610, 4620, 4680, 6410, 6490, 8410 and 8490.

  19. #139
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default

    Quote Originally Posted by skimask View Post

    Previous Release: 2.45

    * Adds support for PIC12F508, 509, 683, PIC16F505, 684, 688, 716, 737, 747, 767, 777, 87, 88, PIC18F2331, 2431, 2515, 2525, 2585, 2610, 2620, 2680, 4331, 4431, 4515, 4525, 4585, 4610, 4620, 4680, 6410, 6490, 8410 and 8490.
    I have 2.46

  20. #140
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by savnik View Post
    I have 2.46
    Well, if TMR0IF (or T0IF for that matter) doesn't work, then just change the code to access the interrupt flag bit directly from the applicable register.

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

    Default

    Microchip can't make up thier mind on what they want to call things. In most 16F's it's called T0IF, and in the 18F's it's TMR0IF, but for some reason, in a 16F88 it's also called TMR0IF. It's the same with the T0IE/TMR0IE.

    Fortunately, we aren't stuck with whatever they decide to call things.

    Just add the 2 highlighted lines, and you should be fine. (no spaces before them)
    Code:
    ASM
    T0IF = TMR0IF
    T0IE = TMR0IE
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,  _ToggleLED1,   PBP,  yes
            INT_Handler   TMR0_INT,  _ToggleLED2,   PBP,  yes
            INT_Handler   TMR1_INT,  _ClockCount,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    
        INT_ENABLE   INT_INT     ; enable external (INT) interrupts
        INT_ENABLE  TMR0_INT     ; enable Timer 0 interrupts
        INT_ENABLE  TMR1_INT     ; Enable Timer 1 Interrupts  
    ENDASM
    DT

  22. #142
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Smile

    Thank you.
    Now it's work.

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

    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.

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

    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

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

    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.

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

    Default

    Well, if I look at my girlfriend ... Moon's and Mood's have the same period, 27.3 days.

    Don't know how that fit's in with you though
    <br>
    DT

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

    Default

    Yeah, it remind me something... sometimes i'm glad to be 'single'
    Last edited by mister_e; - 31st December 2006 at 13:49.
    Steve

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

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

    Default

    Steve,

    I got my parts in for USB (gotta love ebay), and I've built up a breadboard with a 4550 and LED's, switches etc.
    I've looked at the example from post #143, the second one, with DT_INTS, and found two problems. The ...

    INTCON = %10100000 ' Enable global and TMR0 interrupts

    was causing the TMR0 interrupts to start servicing the USB before it was initialized. DT_INTS handles all the interrupt enable bits, so you don't need it anyway.

    The other problem was ...

    goto skipmacro

    was skipping over the interrupt defintion. That section of code needs to execute so that it can handle the enable bits and setup a couple other variables.

    Once I made those changes, the program works as expected, and never looses connection.
    <hr>
    But here's the good part,

    After going through the USB18.ASM file and seeing how things worked, it soon became apparent that those routines are setup to use the USB interrupts(even though PBP doesn't use them that way). It just needs a "kick-start" to get it going. The "kick-start" is simply a tight loop servicing the USB until the driver gets to the "CONFIGURED_STATE". After that it takes off and handles itself.

    But the best part is that it doesn't use ANY PBP system variables to service the USB. So the whole thing can be treated like ASM interrupts, and tied directly into the USB_INT interrupt.

    This also seems to improve the response time since it can react immediately to each step of the USB protocol, instead of after each interval of the timer, or whenever ON INTERRUPT get's around to it, but I don't have any hard data to back that up yet.

    Here's your PIC program from the [USBDemo, something to learn USB a little bit ]thread /.zip file.
    Modified to use DT_INTS-18 and the USB interrupt.
    All the other files are the same.

    http://www.darreltaylor.com/files/USBDemo2_DT.txt

    Works great with the "Mister E USBDemo" program.
    <br>
    DT

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

    Default


    Yup it's working really well indeed. Interesting how it could be handled as ASM... Being said, it open a wide range of USB testpoints as well.

    Oh... when i compiled your example i got an error message... Config fuses related... in this line
    Code:
        __CONFIG    _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEM_OFF_1H . . . . . .
    Must be _FCMEN_OFF_1H

    Thank you very much Darrel for your time on this one!

    Now, i have to read the USB18.ASM file to understand WHY it's working like that now, AND to see what else we can do with

    ; Modified by Darrel Taylor, Don't blame Steve
    Last edited by mister_e; - 7th January 2007 at 11:15.
    Steve

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

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

    Default

    Quote Originally Posted by mister_e View Post
    Must be _FCMEN_OFF_1H
    Interesting, I got the same error with your's. Except I had to change it to _FC_MEM

    After further review I see the P18F4550.inc file in my "MPASM Suite" folder shows these configs for CONFIG1H
    Code:
    ;----- CONFIG1H Options --------------------------------------------------
    _FOSC_XT_XT_1H       EQU  H'F0'    ; XT oscillator, XT used by USB
    _FOSC_XTPLL_XT_1H    EQU  H'F2'    ; XT oscillator, PLL enabled, XT used by USB
    _FOSC_ECIO_EC_1H     EQU  H'F4'    ; External clock, port function on RA6, EC used by USB
    _FOSC_EC_EC_1H       EQU  H'F5'    ; External clock, CLKOUT on RA6, EC used by USB
    _FOSC_ECPLLIO_EC_1H  EQU  H'F6'    ; External clock, PLL enabled, port function on RA6, EC used by USB
    _FOSC_ECPLL_EC_1H    EQU  H'F7'    ; External clock, PLL enabled, CLKOUT on RA6, EC used by USB
    _FOSC_INTOSCIO_EC_1H EQU  H'F8'    ; Internal oscillator, port function on RA6, EC used by USB
    _FOSC_INTOSC_EC_1H   EQU  H'F9'    ; Internal oscillator, CLKOUT on RA6, EC used by USB
    _FOSC_INTOSC_XT_1H   EQU  H'FA'    ; Internal oscillator, XT used by USB
    _FOSC_INTOSC_HS_1H   EQU  H'FB'    ; Internal oscillator, HS used by USB
    _FOSC_HS_1H          EQU  H'FC'    ; HS oscillator, HS used by USB
    _FOSC_HSPLL_HS_1H    EQU  H'FE'    ; HS oscillator, PLL enabled, HS used by USB
    
    _FCMEM_OFF_1H        EQU  H'BF'    ; Fail-Safe Clock Monitor disabled
    _FCMEM_ON_1H         EQU  H'FF'    ; Fail-Safe Clock Monitor enabled
    
    _IESO_OFF_1H         EQU  H'7F'    ; Oscillator Switchover mode disabled
    _IESO_ON_1H          EQU  H'FF'    ; Oscillator Switchover mode enabled
    Is yours different?

    If you want more info on the ASM handling of the USB_INT, I can elaborate some.
    <br>
    DT

  31. #151
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Interesting, I got the same error with your's. Except I had to change it to _FC_MEM

    After further review I see the P18F4550.inc file in my "MPASM Suite" folder shows these configs for CONFIG1H

    Is yours different?

    If you want more info on the ASM handling of the USB_INT, I can elaborate some.
    <br>
    Just checked mine for grins...
    I've got FCMEM in my 4550.INC file

    Also checked the file straight from the .zip file from Microchip, it's the same.

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

    Default

    Yup! seems mine is different... looking on another forum thread (12 Bytes code one ) i know we don't have the same MPLAB version... 7.50 Here, MPASM 5.06

    Here's a .inc file quote]
    Code:
    _FOSC_HS_1H          EQU  H'FC'    ; HS oscillator, HS used by USB
    _FOSC_HSPLL_HS_1H    EQU  H'FE'    ; HS oscillator, PLL enabled, HS used by USB
    
    _FCMEN_OFF_1H        EQU  H'BF'    ; Fail-Safe Clock Monitor disabled
    _FCMEN_ON_1H         EQU  H'FF'    ; Fail-Safe Clock Monitor enabled
    
    _IESO_OFF_1H         EQU  H'7F'    ; Oscillator Switchover mode disabled
    _IESO_ON_1H          EQU  H'FF'    ; Oscillator Switchover mode enabled
    and above... with the new CONFIG plah plah...
    Code:
    ;   Fail-Safe Clock Monitor Enable bit:
    ;     FCMEN = OFF          Fail-Safe Clock Monitor disabled
    ;     FCMEN = ON           Fail-Safe Clock Monitor enabled
    Anyways.. it's no surprise at all that Microchip change it from a version to another

    If you want more info on the ASM handling of the USB_INT, I can elaborate some.

    EDIT: i'll download the new MPLAB version and see what's different or Still the same... interesting...

    EDIT #2 : Just remove and re-install V7.50 (No i never download a interim version) and FCMEN is still good. Maybe they discover that Fail safe Clock Monitor Emable make no sense? Same as mixing Moon and Mood :-]
    Last edited by mister_e; - 7th January 2007 at 12:13.
    Steve

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

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

    Default

    Hmm, I think we have a Spock moment here... "Fascinating!".

    OK, 3AM here, sleep first. ASM Interrupts tomorrow.

    EDIT #2 : Just remove and re-install V7.50 (No i never download a interim version) and FCMEN is still good. Maybe they discover that Fail safe Clock Monitor Emable make no sense? Same as mixing Moon and Mood :-]
    Looks like it's time for an upgrade on my end. Arrrrgh!
    But here, let me shoot the moon first.

    <table width=200 height=150><tr><td bgcolor="White" align=center><b>Censored</b></td></tr></table>
    Whew!, You're lucky that didn't go through.
    <br>
    DT

  34. #154
    Join Date
    Jan 2007
    Posts
    2

    Default version of the compiler?

    What version of the compiler should be used? Thanks,

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

    Default

    2.46 or higher (2.47 here)

    MPASM... just download the latest version of MPLAB 7.51 (maybe 7.52 now).
    Steve

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

  36. #156
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    562

    Default Can nested gosubs be used from within PBP instant Interrupt

    Hi,

    I need to call a subroutine from within a low priority PBP instant interrupt on a PIC 18F452. I am using both High Priority and Low Priority Interrupts.

    I need to know whether PBP uses a software stack for its gosub calls or use the PIC18 stack pointer. I am concerned if calling a nested gosub from within a PBP InstInt would cause stack overflow.
    Regards

    Sougata

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

    Default

    PBP uses the hardware Stack. But with 31 levels on the 18F's, you have to be pretty sloppy to overflow it.

    The PIC itself uses the Hardware Stack to handle an interrupt. But, DT_INTS does NOT use the Hardware Stack. It essentially uses a 2-level software stack. 1 for High Priority, and 1 for Low.

    Once in an interrupt, it's OK to call a subroutine, as long as both HIGH and LOW priorities can never call the same routine at the same time.

    HTH,
    DT

  38. #158
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    562

    Thumbs up Thanks Darrel

    Dear Darrel,

    Thank you for the reply. I am using ASM interrupts on your system for the the high priority and your system already uses the shadow register for HP (retfie fast).

    My main routine has deep calls and in the low priority interrupts I am using PBP. I was actually overflowing the stack causing a MCU reset (configured for reset under STACK Over/underflow). I have re-structured my code to handle it already.

    I must thank you once again for the great job you have done. It is not only about using PBP in Interrupts it is more manageable than asm.
    Regards

    Sougata

  39. #159
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Default Ad_int Problems

    DT,

    I'm trying to force an interrupt whenever the voltage on my analog input pin changes (connected to a 5k POT and RA:0, 16F88).

    I was hopping that AD_INT handler would fire when ever the POT was adjusted but it doesn't.

    I can read the POT voltage ok in my program, so I think all the analog stuff is set ok.

    Is what I am trying to do gonna work or not?

    Squib

  40. #160
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    562

    Default AD_INT does not work that way

    Hi,
    an interrupt whenever the voltage on my analog input pin changes
    The ADC takes a finite time to complete its conversion. When the conversion is complete the AD_INT flag is set. This means that you should always start your conversion manually. However your PIC16F88 has a compare module. That can automatically setup periodic conversion of your AD module. So you would be getting interrupts from the AD_INT that a new value is available. Just read the AD results and compare it with the previous one to find out if your pot has been changed. Please note do not expect two consecutive conversions to be exactly equal even if you are not touching the pot. Supply, layout, noise, blah, blah...... . So compare it for a change of value within a range.
    Regards

    Sougata

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 22:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 21:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 21: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, 04:11

Members who have read this thread : 32

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