Menu

on interrupt

Help
2009-09-03
2013-05-30
  • Nobody/Anonymous

    What do I need to do to set up and use this feature:
    On Interrupt UsartRX1Ready call XXX
    how do I define what rx1 is?
    where can I find documentation on the on interrupt command?

     
    • Nobody/Anonymous

      Interrupt by receive usart-1 will be enabled, then:

      When some data is received via usart-1 an interrupt will occur, then XXX subroutine will be called, when executed the program will come back to the point where was interrupted.

       
    • Nobody/Anonymous

      but what pin is the interrupt on or where do i set it?

       
    • Nobody/Anonymous

      usart is a hardware inside your pic, it depends on the model you use, have a look to the datasheet of your pic, look for section:

      Universal synchronous asynchronous receiver transmiter (USART) module.

      Or in Pin Diagram look for RX and TX pins...

      But these are not interrupt pins, just usart pins, that's a harware module for rs232 comunication inside your PIC (if it has);  you can enable an interrupt when some data is present at RX pin.

       
    • Nobody/Anonymous

      thank you, finally some clarification

       
    • Nobody/Anonymous

      Here is what I got, but it is not working:
      #chip 16F916, 4 'mhz
      #config OSC=INTOSC, MCLRE=off, WDT=off
      #mem 256 'Chip has 256 bytes

      On Interrupt UsartRX1Ready call serial_in

      lcdcon = 0
      dim temp as byte
      dim temp2 as byte

      #define RecAHigh portc.7 off
      #define RecAlow portc.7 on
      Initser 1,r1200, 1+waitforstart, 8, 1, none, invert
      dir portc.1 out
      dir portc.7 in 'serial

      main:
      epread 1, aa
      if aa = 1 then set portc.1 on
      if aa = 0 then set portc.1 off
      goto main

      Sub serial_in
      SerReceive 1, temp 
      SerReceive 1, temp2
      temp = temp - 97 'a=1 b=2, etc
      temp2 = temp2 - 48 ' sets number to actual not ascii value
      EPWrite temp, temp2
      End Sub 

       
    • Nobody/Anonymous

      I think you are using software serial routines.
      If you don't have it, download and use last update:
      http://gcbasic.sourceforge.net/update.html

      In folder: include/lowlevel , file: usart.h, there you can see hardware usart functions.

       
    • Hugh Considine

      Hugh Considine - 2009-09-05

      There should be a help file named gcbasic.chm included with GCBASIC. If you can't access that, there's also online help. I've recently uploaded the help for the update.zip version of GCBASIC to http://gcbasic.sourceforge.net/newfiles/help/ .

      The page about On Interrupt is here: http://gcbasic.sourceforge.net/newfiles/help/oninterrupt.htm

       
    • Nobody/Anonymous

      so I read it, but It is a little confusing, what am I missing from my code to make it work?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.