12F683 and DT Instant Interrupts


Closed Thread
Results 1 to 27 of 27

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    It's not absolutely required, unless the reload value is calculated.

    When you have a fixed value like that, you can be pretty sure the LowByte won't overflow before it loads the HighByte.

    However, you'll need to load the LowByte first, if you're not turning the timer off. And you'll also need to subtract 7 from the number you have, which is adjusted for a reload that does turn the timer off.
    <br>
    DT

  2. #2
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default Elegent way to exit the handler and goto main code

    In my code I do a bunch of stuff then wait doing nothing for an interrupt some mS later, then when that happens I want to run my bunch of stuff again, forever and ever. Rather than return to where the interrupt occurred in my 'wait doing nothing'....

    I see the obvious way is to put my 'bunch of stuff code in the interrupt handler subroutine, but that makes the int handler routine very big and the 'main' code very small. Looks all wrong to me. Is that the way to do it or is there a proper way to get the int handler to go to my 'bunch of stuff' rather than return to where it was interrupted from ?

    Code:
    LED1   VAR  GPIO.1
    
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    T1CON = $01                ; Prescaler = 1, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    
    Main:
         Big bunch of stuff
    
    wait_here:
         pause 1
         Goto wait_here    'wait for an interrupt here
    (Return from Interrupt would hang here ?)
    
    GOTO Main    'should never happen
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         
        T1CON = %0
        TMR1L = $23
        TMR1H = $A8
        T1CON = %1
        TOGGLE LED1    
    @ INT_RETURN

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking The KISS way ...

    Hi, Mr Sneezy

    I do not know what's your final project ... BUT :

    Did you ever considered the R/C Framerate is an excellent timebase with 22.5 ms granularity ??? ( looks Graupner/JR remote ??? )

    No need for heavy interrupt implementing, then.

    just a simple idea ...

    Alain
    Last edited by Acetronics2; - 12th November 2008 at 11:08.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default Generate PPM frames at 22.5mS rate

    Quote Originally Posted by Acetronics View Post
    Hi, Mr Sneezy

    I do not know what's your final project ... BUT :

    Alain
    but you're very very close Alain.....

    Except in my application I'm needing to generate an 8ch PPM pulse frame at 22.5mS rate from scratch.

    To cut to the chase what I want to do is build a simple RC TX radio eliminator so I can test prototype 2.4Ghz transmitter modules in the field (range tests etc etc) without needing a second person to wiggle the sticks on the radio (it uses Futaba compatible TX modules). I did the obvious thing and looked for existing projects but they all seem to decode PPM frames not create them...

    The app will change the PPM period for two channels (at least) slowly so the servos move at the RX end while I move away doing testing (sometimes Km's). The remaining channels will just be 1.5mS center position all the time.

    Sorry for the apparently newbie programming questions, I've actually written some quite large complex code in the past (way way past) but I do it so infrequently now I have to go back to basics at the start of a new project like a beginner. I never seem to do a similar project twice which doesn't help.

    I guess another way of asking my question is can I have a lot of code in the interrupt handler subroutine ? Or could that bugger up the interrupt code ?

    Thanks,
    Martin

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi, Martin

    I already have it here aboard a 12F675 ... just change repeating time to match the 22.5 ms ( was originally intended for a MPX frame ) lol !!!

    But do no want to tear your pleasure at all ... if it's your wish to discover interrupt charms !

    I' d recommand you to trim the first channel to 1.1 ms, the second to 1.2, third to 1.3 ... and so on. That will make later channel identification much easier.

    My application was static demo of boats without using RF ... ( Other Boats on "live show" at same time ... for the Warwick show !).

    Humouristically yours ...

    Alain
    Last edited by Acetronics2; - 12th November 2008 at 13:25.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    BTW ...

    I remember there's a non-PCM other solution ...

    PULSIN + some little lines can detect bad pulse duration ( = glitches = max. range) just place a servo in a preset position if glitches appear ( you can allow as much glitches as you want before entering " Fail safe" )

    Based on that ... you just take a receiver a batt and a servo, or your plane ... with you while the Tx keeps steady.

    I use it aboard a Glo Driver : Engine is slammed to idle, or cut, if too much glitches.

    Already saved many planes ... including scale championship ones !!!


    PCM have that feature ... so, just need to use it !!!

    My MC18 Transmitter also has a Servo-test feature ... that move automatically servos one after the other ...


    I didn't write it ... but why not use the coder's signal through the "Pupil's plug" ???
    Alain
    Last edited by Acetronics2; - 12th November 2008 at 14:10.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Martin

    I already have it here aboard a 12F675 ... just change repeating time to match the 22.5 ms ( was originally intended for a MPX frame ) lol !!!

    Alain
    Hi Alain,

    Yes thanks, if you have a code that does the same job I'd like to see it. I'll either try it out as you wrote it or use it for inspiration to finish mine. You could send it via a personal message or post it here. I have a couple of 12F675's in my bits box.

    Going on to your second reply, that is a good idea about the servo positions. To take it one step further I could have a PIC analysing the channel outputs over time and coming up with a sort of 'error rate' like we use on digital communications bearers here. Going all the way would have a PIC with LCD, displaying error rate (glitches/holds per minute ?) for each channel plus a summed figure. That way I can compare different 2.4Ghz receiver versions against a mathmatical benchmark...

    Oh boy, I'd better go do something else before this turns into a monster project !

    Martin

  8. #8
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default Hanging the interrupt registers ?

    Getting back on topic with DT int code. Is it a bad thing to put GOTO's or GOSUB'S inside the interrupt handler ? Therefore maybe never seeing the @ INT_RETURN

    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:

    T1CON = %0
    TMR1L = $23
    TMR1H = $A8
    T1CON = %1
    TOGGLE LED1

    GOTO MAIN 'is this dangerous ?

    @ INT_RETURN

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 23:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts