Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
ZX24N Interrupts

 
Post new topic   Reply to topic    Forum Index -> ZX-24
Author Message
pdubinsky



Joined: 25 Nov 2005
Posts: 66
Location: South Carolina

Posted: 17 December 2009, 18:50 PM    Post subject: ZX24N Interrupts Reply with quote

Back some time ago, there was a discussion on a tachometer app in which someone suggested using a native mode 24N and an ISR routine to capture pulse timing. The discussion moved to InputCapture and never discussed using the interrupts again.

I'm curious, has anyone used the ISR routines in the 24N? Is there any practical difference between using the external interrupts as opposed to the pin change interrupts (other than the limited pins necessary for the the external interrupts)? Are variables used as storage in the ISR routine globally available to sub main?

TIA & Happy Holidays,
Paul
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 17 December 2009, 19:24 PM    Post subject: Re: ZX24N Interrupts Reply with quote

pdubinsky wrote:
Is there any practical difference between using the external interrupts as opposed to the pin change interrupts[...]?
One difference is that with each external interrupt there is only possible interrupt source (unless you combine them using external hardware). In contrast, with a pin change interrupt there could be up to 8 possible sources of the interrupt depending on the pin change interrupt mask that you use. Multiple interrupt sources requires additional logic in your program to sort out which one (or more) of the sources triggered the interrupt.

pdubinsky wrote:
Are variables used as storage in the ISR routine globally available to sub main?
The visibility rules are identical to non-ISR procedures. That is, if you define a variable within a procedure (or ISR), that variable will not be visible from other procedures. In order to share data between an ISR and other procedures you must use module-level variables.

There are several issues to consider when sharing data between procedures. Firstly, for multi-byte variables (e.g. Integer, Long) you must enclose accesses to the variable in an Atomic block. This provides atomic access to the variable, guaranteeing that another procedure will not be allowed to run (possibly accessing the same data element) in the middle of the multi-byte access. Note, too, that read-modify-write operations on all variables (regardless of size) must be similarly protected.

Secondly, when an ISR shares data with other procedures you must define the variables with the Volatile attribute. This attribute tells the compiler that the variable can be modified at any time by and, therefore, the compiler cannot make certain optimizations.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZX-24 Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group