DT Interrupt and Elapsed Time Running Slow


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44

    Cool DT Interrupt and Elapsed Time Running Slow

    I'm having troubles with Darrel's Interrupts. Being the FNG that I am, most likely it's my inexperience that’s the trouble and nothing to do with Darrel’s interrupts.

    I believe I have the trouble narrowed down to T0CON and T1CON settings. I have a simple program that I’m using to learn the interrupts and elapsed time.

    When I configure T0CON or T1CON, the interrupts work, but they run slow. T1CON I’m setting for the DT “ClockCount”. I get the clock running, but it takes 60 seconds for the clock to count up to about 3-4 seconds. I’ve read the datasheet on prescaler , post-scaler, internal timer scaling, external clocks etc. I’m not getting something correct.

    Also when I enable T0CON or T1CON, I get bugs in my “DEBUG” some settings make it send garbage, some settings have a mix of good characters and invalid characters.

    Debug is using a MAX232, and a DYNEX USB to Serial adapter ( no serial on my PC ) the MAX232 is already on the Micro Chip PICDEM 2+ proto board.

    Also I get a Warning on Compile when I include the Interrupt files. “WARNING[207] : FOUND LABEL AFTER COLUMN 1. (INT_LIST)” I don’t know if that has anything to with it, but it’s another clue.

    I’m using the 18F2550 pic, PBP version 2.50, DT’s latest interrupts Ver. 3.3, DT’s Elapsed-18 Ver. 1.0.
    I’m using the internal 8 MHz OSC, no external clock is connected to the device.
    I’m not using any USB, I don’t think I can use the USB without an external OSC, that’s a problem to take on if/when I want to figure out USB stuff.

    I’ll include my test program as an .txt attachment (renamed from .pbp). Don’t poke too much fun at it, I’m just learning.

    This stuff is addicting.
    Thanks,
    Shane
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default

    at first glance you don't have the ClockCount ISR that you have timer1 enabled to go to.

    David

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


    Did you find this post helpful? Yes | No

    Default

    It's include in the Elapsed_INT-18
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    The Timer1 registers are all handled by Elapsed_INT-18.bas, so you shouldn't be changing T1CON. One problem there is that you turned on the RD16 bit in T1CON, but Elapsed_INT-18 doesn't use the timer that way, so it would have been re-loading the wrong values, probably with much longer periods.

    For the DEBUG issue ...
    Any statements that are timed by software ... Pulsin/out, Serin/out, pause, Debug and others will be disturbed by interrupts. That's just the nature of interrupts.

    You should use Hardware whenever possible.
    For serial data, use the USART.

    And for the FOUND LABEL AFTER COLUMN 1. (INT_LIST) warning.
    You can either remove the extra indentation before the INT_LIST macro so that the line starts in column 1.
    Or, add this line to the program
    Code:
    @ errorlevel -207
    Which stops MPASM from giving the warning.

    hth,
    DT

  5. #5
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel, I removed the indent on the "INT_LIST" macro, that took care of the warning. I never thought an indent would make a warning, I searched high and low in my code and your's for any references to "INT_LIST".

    I also stopped changing T1CON settings, I didn't realize you're code was already setting it up.

    I still haven't fixed the debug issue. I thought a quick fix would be to disable the interupts before sending the data out on debug, that didn't work.

    So now I'm learning about the USART you suggested, which has me confused. How do I use the USART without using "SEROUT" if the interupts will interfer with SERIN/OUT?

    Any help on configuration would be great!

    Thanks,
    Shane

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ShaneMichael View Post
    I still haven't fixed the debug issue. I thought a quick fix would be to disable the interupts before sending the data out on debug, that didn't work.
    Disabling the interrupts will disrupt the Elapsed Timer if they are turned off for more than 1/100th of a sec.

    How do I use the USART without using "SEROUT" if the interupts will interfer with SERIN/OUT?
    HSEROUT and HSERIN are for the USART.
    <br>
    DT

  7. #7
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Huh, look at that, HSEROUT is for the USART. Glad you said that, I'm reading the book on SEROUT and going in circles with interupts messing with SERIN/OUT.

    I'll see what I can get going with HSEROUT. I'm sure I'll have more questions as I progress. At least I'm not just trying random settings any more, that's progress!!!

    Thanks,
    Shane

  8. #8
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    OK, HSEROUT is working, and so is the timer interupt. After almost 30 minutes, it was slow about 20 seconds. I'm guessing that could be drift in the internal OSC? It's all I'll need for the current project.

    I used the HSEROUT settings from the PBP manual, I compaired them to the data sheet for the 18F2550, I didn't see anything that I felt like I should change. Learned my lesson with the T1CON settings.

    Thanks for the help.

    For those reading this that are worried about changing from Debug to HSEROUT, it wasn't bad, I used the following Defines:
    Code:
         DEFINE HSER_RCSTA  90h
         DEFINE HSER_TXSTA  20h
         DEFINE HSER_BAUD   9600 
         DEFINE HSER_CLROERR    1
    The HSEROUT looks like this:

    Code:
    Hserout [10," M: ",dec Minutes," S: ",dec Seconds," T: ",dec Ticks,10]
    I'm using the "Serial Communicator" in MicroCode Studio (F4 key)

    The pic is connected to a MAX232, I think this is needed for HSEROUT? Someone correct me if I'm wrong.

    Also I'm using a DYNEX RS232 to USB adapter:

    Model: DX-UBDB9 from BestBuy

    I'm Using Windows VISTA, so I downloaded the latest drivers from their website, and only had moderate issues with VISTA ( mostly operator error )

    Hope this helps out anyone else that has questions about a setup.


    Shane

  9. #9
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default 20h or 24h ?

    The HSER_TXSTA should be 20h or 24h ?

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


    Did you find this post helpful? Yes | No

    Default

    Using the internal OSC sure leads to problems one day or another, even with newer OSC accuracy.

    @8MHz and 9600 baud, it shouldn't matter if you use 24, or 20 for TXSTA as both will return the same error %... BUT assuming some ASM limitations, asking PBP macro to calculate the SPBRG value for you, could give some difference at this point.

    See what a single digit of difference can do

    @8MHz and TXSTA=20,
    if SPBRG=11, err% =8.507%
    if SPBRG=12, err% =0.16
    if SPBRG=13, err% = -6.994%

    When TXSTA=24
    if SPBRG=50, err% =2.124%
    if SPBRG=51, err% =0.16
    if SPBRG=52, err% =-1.73%

    Play safe and set SPBRG yourself.
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 12  ' 9600 Baud @ 8MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    This is where I begun to think about some Standalone Calc software. First was E-Z SPBRG Calculator, then it grows and became PicMultiCalc.

    Download it
    http://www.picbasic.co.uk/forum/atta...7&d=1225550328
    Last edited by mister_e; - 11th May 2009 at 19:08.
    Steve

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

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 18:39
  2. Interrupt RPM and Taylors Elapsed time on 18F4620
    By Tobias in forum mel PIC BASIC Pro
    Replies: 70
    Last Post: - 3rd February 2010, 17:12
  3. Get elapsed time while TIMER samples pulses
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th March 2009, 17:27
  4. Interrupt problem.
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th August 2005, 07:40
  5. My Code get crazy after i add interrupt
    By jetpr in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th May 2005, 05:43

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