In SX Microcontrollers, SX/B Compiler and SX-Key Tool, PJMonty wrote: BBAL, The Sx has an internal clock (RTCC) that can generate interrupts. How often they happen depends on the settings of RTCC. When an interrupt occurs, it literally "interrupts" the computer, stops processing whatever code it was in the middle of, and jumps to address 0. You place code at address 0 that you want executed during the interrupt. When you're done, you return from the interrupt and the SX will pickup exactly where it left off. There are details about how to handle all of this, but that is the essence of what you do and what happens. The typical analogy given is to imagine if telephones didn't have ringers. In order to know if a call was coming, you would have to keep picking up the phone and saying, "Hello?" to see if anyone was calling. That would completely suck and it would occupy a lot of your day because if you didn't do it often enough, it possible that someone would call, you wouldn't check to see if anyone was calling, and they would hang up only to be followed by you checking [i]after[/i] they hung up. An interrupt is like the ringer on the phone - when you hear it, you stop what you're doing, answer the phone, and then hangup and return to what you were doing - far more efficient. Now, imagine that your interrupt was set to 80 khz. All you would have to do in your interrupt code is toggle a bit. The reason for 80 khz is that on every other interrupt, you would toggle the bit high or low. This would give you a 40 khz output with a 50% duty cycle. In addition, you could do anything else you wanted in your main code and the 40 khz output would continue unimpeded. It's nifty and incredibly powerful stuff, but it's also tricky since there are new and interesting ways to have buggy code. [list]Thanks, PeterM[/list] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=107862#m108402 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)