how to return to a specific location after dt_ints


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2009
    Posts
    4

    Default how to return to a specific location after dt_ints

    hi all,

    firstly i would like to thank mr. Darrel Taylor for his brilliant dt_ints..!

    and secondly....

    I think i have read about it somwhere on this forum but cannot find it again!

    could anyone tell me if there is a way to return to a specific label after a dt_int interrupt rather than the point at which the it occurred??

    kindest regards in advance

    ian.

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


    Did you find this post helpful? Yes | No

    Default

    Hi ian,

    If you're using an 18F, there's this ...

    http://www.picbasic.co.uk/forum/show...7719#post67719

    Although I still don't recommend it.
    <br>
    DT

  3. #3
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Modifying the stack like that is an advanced programming technique, and can be used with great success. However, since most PBP programmers find it difficult enough just to successfully author a rudimentary interrupt routine, newbies should avoid it.

    A better way for the inexperienced is to sit in a loop and wait for a flag that is set in your interrupt. (A flag is typically a bit variable, changed between 0 and 1.) When the loop detects the flag, jump to your target.

  4. #4
    Join Date
    Jun 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    thanks alot guys,

    i can't sit in a loop and wait...looks like i got some experimenting to do..
    .....better crack open a can or two..three....four...

    best regards

    ian

  5. #5
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Just remember that sometimes a loop has lots of code in it. Just because you are sitting in a loop and waiting does not mean you are doing nothing.

  6. #6
    Join Date
    Jun 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default rpm measurement

    Hi all,

    Thank you for a great forum....i mean REALLY great!

    I don't post very often, usually only when i need help..i know it's a little selfish but....

    any way! i am designing a controller for a plastic film winding machine,

    all my code works very well, i am using darrel's brilliant dt_ints for ccp1 ,portb change, serial usart and tmr0.

    ok, now for my "issue" :
    i am using ccp2 for hpwm and also 2 off sofware pwm's

    when i have high rpm's you can hear the software rpm signal being "coloured" by the ccp1 interrupts, it is not a problem as the pwm works very well, it is more of a niggle than anything.


    i would like to include the rpm calculation in the ccp1 interrupt but there is no way i can at the moment.

    i know dt_ints saves data before and restores data after the interrupt, would it be any quicker to use assembly ?..well i suppose it would but i don't know where to start with interrupts in assembly


    i already run the tacho through a flip flop to reduce the freq and due to responce times i don't really want to capture *4 or 16 rising edges.

    if any one could start me off with an assembly call to a ccp1 int handler and how to return from it i would be really gratefull!


    thanks in advance and p.s. here are my code snippetts..(please don't laugh at my code,,, i am still learning!)









    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 1/21/2010 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    ''device=18f2620

    osccon.0=1 ' internal osc
    osccon.4=1 ' int oscillator
    osccon.5=1 ' scaling for
    osccon.6=1 ' 8 MHZ

    DEFINE ADC_BITS 8 'Set number of bits in result
    DEFINE ADC_CLOCK 3 'Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 5 'Set sampling time in microseconds

    CCP1CON = %00000100 'capture timer0 every falling edge portc.2

    t0con.0=0 'timer0 on
    t0con.1=1
    t0con.2=0
    t0con.3=0
    t0con.5=0
    t0con.6=0
    t0con.7=1
    'yadda yadda yadda! etc






    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?

    int_handler rx_int, _read_usart, pbp, yes
    INT_Handler CCP1_INT, _get_pulsewidth, PBP, yes
    int_handler int0_int, _feed_request, pbp, yes
    int_handler int1_int, _heat_request, pbp, yes
    int_handler int2_int, _get_position, pbp, yes
    int_handler tmr0_int, _no_pulse, pbp, yes


    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM















    '------------------------------------------[tacho pulse interrupt routine]---------------------------------------------------
    get_pulsewidth:

    t1con.7=0 'stop the timer
    pulsewidth.lowbyte=tmr0l 'get the low byte timer result
    pulsewidth.highbyte=tmr0h 'get the high byte timer result
    tmr0h=0 'zero the
    tmr0l=0 'timer
    pulse_ok=1
    t1con.7=1 'restart the timer

    @ int_return

    '--------------------------------------[no valid rpm signal, timer1 overflow]-----------------------------------------------
    no_pulse:
    pulse_ok=0
    rpm=0
    @ int_return

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


    Did you find this post helpful? Yes | No

    Default

    Capture mode of CCP1 works with Timer1 or Timer3, and it captures pulses on the CCP1 pin not from Timer0.
    The captured value is stored in the CCPR1L,CCPR1H registers.

    But your CCP int handler stops Timer1, Reads Timer0, clears Timer0 then restarts Timer1.

    I think you need to take a closer look at what's really happening.
    <br>
    DT

  8. #8
    Join Date
    Jun 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    in the immotal words of Homer Simpson

    DOH!

    thankyou D.T.

    sometimes the wood does get in the way of the trees

Similar Threads

  1. Stack over flow with IF THEN RETURN ENDIF???
    By kdoske in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th December 2007, 17:20
  2. IC2 pic 18f452 program problems
    By MrSafe in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 20th September 2007, 18:55
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. Can RESUME replace RETURN in a GOSUB?
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 9th October 2005, 09:03
  5. slow return from subrutine
    By servo260 in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 8th March 2005, 17:33

Members who have read this thread : 1

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