Simple ISR?


Closed Thread
Results 1 to 7 of 7

Thread: Simple ISR?

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232

    Default Simple ISR?

    My project is a 24hr temp logger. Which logs every 15 minutes for the 24hr period. The 15 minute timer is the PBP “SLEEP” command. After 24 hours the application goes to sleep” @sleep”. I want an interrupt on GP2 external interrupt pin to stop the 15min. timer or the “@sleep” and send the program to a PBP routine to RS232 dump to PC. At that time the job is done, unit goes to low power state until power disconnect. I don’t want to use ON INTERRUPT, can’t wait 15min. to print. Once interrupted I don’t need to save any variables, or STATUS or PCLATH (<2k) logging is done, I only need a “goto _printout” placed at location 04. So how do I accomplish that? AND have I missed something of the process?

    Code:
    @ DEVICE PIC12F683,MCLR_OFF,INTRC_OSC_NOCLKOUT ,WDT_ON,BOD_OFF
    @ DEVICE PWRT_ON,FCMEN_OFF,IESO_OFF,PROTECT_ON
    OSCCON=%1110000    
    Define OSC 8
    
         VRCON  = 0         
         ADCON0 = 0         
         OPTION_REG = %01000000  	;rising edge
         ANSEL  = 0    			;digital all
         CMCON0 = 7
         INTCON = %10010000         	;Globle set, GP2 ext int, flg clr
         GPIO=0   
         TRISIO=%00001100		;GPIO.2 input	
    	;GPIO.2 held low until button push +5v
         Blink   var GPIO.4
    
         GOTO Start
         define INTHAND myint
         asm
              myint goto _printlog
                endasm
    Start:  
                  -----     LOG DATA for 24hrs
    Printlog:
    	 -----     RS232 to PC
    	INTCON = %10010000   ;in the case another print out is needed      
    	@sleep
    I’ve written a small INT test program to work this out but I’m not having any luck. On compile I get the error “undefined symbol myint” & “opcode expected instead of myint”
    I remove the myint from the asm line and the opcode error goes away. However I think this is needed as it is the ASM label. This ASM method is right out of the 2.60 manual. What is it I’m not getting? Comments Please!

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    I tried out your code. The only change that needs to be done is in how you define myint

    myint goto _printlog

    myint should start in the 1st column of your file.

  3. #3
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Reply

    Thank you Jerson for your reply. I did not understand the relevance of the first column positions of the instruction. As a matter of fact the manual has the instruction on the first column. This should get me up and running. Thank you again for your response
    Last edited by MOUNTAIN747; - 9th March 2010 at 13:13.

  4. #4
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Reply

    I have written this short piece of code to test the interrupt. IT Works! but only ONCE... For some reason it will not interrupt the second time unless I reset the processor with the power. I can't see a problem. I am resetting INTCON before return to main program. ???

    [
    Code:
    @ DEVICE PIC12F683,MCLR_OFF,INTRC_OSC_NOCLKOUT ,WDT_ON,BOD_OFF
    @ DEVICE PWRT_ON,FCMEN_OFF,IESO_OFF,PROTECT_OFF
    OSCCON=%1110000    
    Define OSC 8
    
         VRCON   =  0         
         ADCON0 =  0         
         OPTION_REG = %01000000  	;rising edge
         ANSEL   =  0    		;digital all
         CMCON0=  7
         INTCON = %10010000         	;GlE set, INTE set, INTF clr
         GPIO=0   
         TRISIO  = %00001100		;GPIO.2 input
          Avar    var byte
          Blink   var GPIO.4
          TX      var GPIO.5
          GOTO Main
    define INTHAND myint
    
    asm
    myint goto _printlog
    endasm
        
    Main:  
                
    Blinkled:
        pause 1000
        for Avar=1 to 4
        HIGH    blink  
        pause   100
        low     blink
        pause 200
        next Avar
                
        Serout2 tx, 84, ["   This is a test, This is only a test",13,10,13,10]  ;print to PC             
        goto Blinkled
    printlog:            
        Serout2 tx, 84, ["   An Interrupt has occured on GP2",13,10,13,10]           
        INTCON=%10010000  ;set GIE, INTE and clear INTF
        goto Main     
        end

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    your printlog is an ISR (interrupt service routine) and should end with a return not a goto main. Try that

  6. #6
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Reply to Jerson

    Jerson,
    Yes, I had forgotten about the address that was pushed on the stack by the interrupt. I tried a RETURN and @RETFIE , the micro locked up for a couple of seconds then restarted, I think by WDT, and would not re-interrupt. I know I have to deal with the stack but RETURN will load an address I don’t want to use. So my challenge it to find a way to POP the stack, discard the address and load a new address while still resetting interrupt bits. It looks like there is NO easy way to do this. I’m sure that is why DT_INT is so popular. By the way thanks again for lending a helping hand to the struggling hobbyist, mainly me. I’ll keep working on this problem and post any success.
    WANTED: easy way to use Ext Interrupt to change the course of a program.

Similar Threads

  1. Simple RF remote control code
    By Bruce in forum Code Examples
    Replies: 13
    Last Post: - 22nd January 2014, 10:45
  2. Simple Blinking LED - WTF!!
    By johnnylynx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st February 2010, 06:19
  3. Replies: 0
    Last Post: - 2nd February 2009, 23:23
  4. Jump from ISR
    By yasser hassani in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 15th May 2008, 20:54
  5. Replies: 4
    Last Post: - 7th September 2005, 14:11

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