TMR0 interrupt and HSERIN


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Posts
    39

    Default TMR0 interrupt and HSERIN

    Hello,
    I have a question about the interrupts. I have a simple program which uses the TMR0 interrupt. Then I have a task which is using HSERIN / HSEROUT and this task is executed each minute. But looks like, that this task cause, that the TMR0 interrupt is not correctly managed, I am loosing seconds when the task is running. I am trying to findout why, because for the waiting operation I am using e.g. this routine, which should not block the OnInterrupt:

    pauseWithInterrupt:
    for k=0 TO 1200
    PAUSE 1
    NEXT k
    return

    My question is what will happen, if I have e.g. the command:

    HSERIN 100, retMail2, [wait ($0D, $0A, $0D, $0A), STR COMMAND\96\$0D]

    And the TMR0 interrupt will arrive, when the HSERIN is waiting. Based on the manual, I expect, that the program will jump to On Interrupt after the HSERIN command will finish. Is it true? It cannot happen, that the interrupt is lost?

    Becuase I have in On Interrupt:
    On Interrupt Goto intManagement

    disable
    intManagement:
    if (INTCON.2 == 1) then
    ticks = ticks + 1 ' Count pieces of seconds
    If ticks < 61 Then tiexit
    toggle ACTIVITY_LED
    ticks = 0 'One second elasped - update time
    if (skipSecIncr <> 1) then second = second + 1
    skipSecIncr = 0
    tiexit:
    INTCON.2 = 0
    endif
    INTCON.7 = 1
    resume

    Because I was thinking, if the TMR0 interrupt is fired and I will not perform the INTCON.2 = 0 and INTCON.7 = 1 then the TMR0 is not increased - not counted. So I should not do any operation, which will take more than 16 ms. Is it true?

    I am using this setting:

    'interrupt for timer
    T0CON = $C5
    RCON.7 = 0
    INTCON = $a0 'enable TMR0 interrupts and global interrupt


    I think, the possible solution, how to prolong this 16 ms period is to use prescaller for TMR0.
    But my general question is if TMR0 interrupt is running all the time, even if the INTCON.2 = 1
    and INTCON.7 = 0

    I am using the PIC 18F2520
    Thanks Robert

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I think a better solution would be to use Darrel Taylor's Instant Interrupts. The "on interrupt go to" structure in PBP is not a "true" interrupt, in that it doesn't go to the ISR at the end of the present instruction cycle.
    Charles Linquist

  3. #3
    Join Date
    Jan 2007
    Posts
    39


    Did you find this post helpful? Yes | No

    Default Hserin

    I think, that the question is, if the interrupt is called, when I am using long operations like e.g.
    HSERIN 100, retMail2, [wait ($0D, $0A, $0D, $0A), STR COMMAND\96\$0D]

    Becuase I have realized, that the HSERIN command is not probably terminated by the interrupt and it is waiting till the end.
    So the only solution is to use e.g. longer TMR0 interrupt - like to switch the TMR0 to 16 bit, then the interrupt is called each half second and in that case it is always managed.

    Are my assuptions correct?

Similar Threads

  1. HSERIN with/without interrupt
    By macinug in forum Serial
    Replies: 3
    Last Post: - 19th January 2009, 17:03
  2. RTC via TMR0 + HSERIN and 16F916
    By boban in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th March 2008, 12:51
  3. Usbin and hserin
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th October 2007, 15:26
  4. Can a TMR interrupt stops HSERIN?
    By SergioRM in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th January 2006, 01:07
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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