Menu

ReadTable corrupts on interrupt

lou
2010-08-11
2013-05-30
  • lou

    lou - 2010-08-11

    I have a program that is making use of two separate tables being read by the ReadTable command.  I have one ReadTable command on a interrupt handler and the second on the main loop.  I'm experiencing sporadic data corruption and I believe the problem lies in the ReadTable command using variables that are not saved as part of the interrupt context.  So when I get an interrupt in the middle of a ReadTable access, the access gets corrupted.  I believe the data pointer is the culprit here.  I'm not sure how to work around this without going into the assembly code.

     
  • lou

    lou - 2010-08-11

    The chip is a 16F690 if that makes a difference.

     
  • lou

    lou - 2010-08-12

    I found a quick fix for this problem.  Make sure you save the DataPointer before using ReadTable on an interrupt handler and restore it before exiting it:

    Sub TimerHandler
       saveptr = DataPointer
       ReadTable (Table1, index, output)
       …
       DataPointer = saveptr
    end Sub

     
  • Hugh Considine

    Hugh Considine - 2010-09-10

    I've now added a bit of code to GCBASIC that should save the DataPointer variable properly in the interrupt. Thanks for posting, and sorry for the delay in replying!

    The fix is at the usual address, http://gcbasic.sourceforge.net/newfiles/update-nochipdata.zip.

     

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.