Any Simple ASM interupt code examples out there?


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171

    Default Any Simple ASM interupt code examples out there?

    Am looking for a simple interupt code example that will just escape to the interupt on rollover of tmr. I need to have a reliable timebase for a program I've got where it needs to exit with an ASM interupt.

    Thanks in advance

  2. #2
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default Interrupts

    Let me be the first to point you here.......
    http://www.picbasic.co.uk/forum/showthread.php?t=3251
    It has to be simple, even I can use it.

    Hope it helps.
    "It will never happen here!" just happened here.
    My thoughts and prayers for Sandy Hook victims and families.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by George View Post
    Am looking for a simple interupt code example that will just escape to the interupt on rollover of tmr. I need to have a reliable timebase for a program I've got where it needs to exit with an ASM interupt.

    Thanks in advance
    Section 9.3 of the PBP manual, just set up your timer module, change the references from portb.0 over to the timer, and you're set...

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


    Did you find this post helpful? Yes | No

    Default

    Now we have 3 version of interrupts here

    ASM
    Instant Interrupt
    PBP ON interrupt

    the easiests are PBP, and Darrel Instant interrupts. More efficient pure ASM... but Darrel's instant is really f**** close of the ASM.

    As always, nobody's give the PIC # and the expected results... hard to point out the best and ultimate Solution.... it won't break your keyboard to type few more lines. If so, i'll send you a brand new one... i buy keyboard in slap of 100's. 1-2 buck each.
    Last edited by mister_e; - 22nd March 2007 at 22:20.
    Steve

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

  5. #5
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    The PIC is a 16F676 so it's pretty tight with code space and variables (have tried DT's code but it runs out of variables), I'm just trying to exit from a serin command where there is always noise coming into the port (AM reciever module) just to increment a timer - and turn device off after a predetermined time.
    Last edited by George; - 23rd March 2007 at 04:23.

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


    Did you find this post helpful? Yes | No

    Default

    Can you post your code here?

    To me a PIC with a USART would be more interesting in this case.
    Steve

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

  7. #7
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Lightbulb You need not use interrupt

    Hi,

    Even if you are not using interrupts the timer0 rollover (INTCON.2, T0IF) gets set. So you can periodically check if the flag is set. To get proper timeout your main body loop should not execute for more than the timer0 rollover period. Even if it does then you miss a few ticks but still get some dirty timing. So here is how it goes
    Code:
        OPTION_REG = %11000111     ' SET PRESCALE HERE 256 (Datasheet PAGE 14)
        ' @4MHz AND PRESCALE TIMER0 ROLLSOVER IN ABOUT 65.5 mS
        TIME_COUNTER VAR WORD      ' MAY BE A BYTE ALSO
        
        INTCON = 0
        TIME_COUNTER = 0
        MAIN_LOOP:
        
        ' DO WHATEVER
        IF INTCON.2 = 1 THEN       ' CHECK IF TIMER ROLLED OVER
           INTCON.2 = 0            ' CLEAR THE HARDWARE FLAG
           TMR0     = 0            ' CLEAR TIMER0 IF YOU WISH
           TIME_COUNTER = TIME_COUNTER + 1 ' INCREMENT YOUR COUNTER
        ENDIF
           IF TIME_COUNTER > PRESET THEN QUIT_LOOP
           
    
        GOTO MAIN_LOOP
           
        QUIT_LOOP:
        
        ' TIME OVER DO WHATEVER
    PRESET is hard coded. In your main routine when you receive a valid signal don't forget to clear (Reset) the timer_counter variable and any pending ticks i.e., INTCON.2
    Hope this helps
    Regards

    Sougata

Similar Threads

  1. decoding quadrature encoders
    By ice in forum mel PIC BASIC Pro
    Replies: 93
    Last Post: - 28th February 2017, 09:02
  2. ASM code
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 1st March 2010, 23:55
  3. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. ASM Interrupts with BASIC code?
    By Desterline in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 31st October 2003, 19:21

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