In SX Microcontrollers, SX/B Compiler and SX-Key Tool, kmonsx wrote: Thanks everyone for the posts. I appreciate the discussion. PJV: I modified your main routine because the logic was reversed, my PC software raises PCAck high when it has received a byte. I think I did this right. [code] Main ;sit here while all the action occurs ion the interrupt jnb PCAck,@Main ;actually hi for an ack ;sb PCAck ;test pc acnowledgement (lo for ack) clrb AdvisePC ; jmp Main ; [/code] If you are interested, it produced all zeros. And I can tell by the rate at which it was transferring to the PC, it was too slow, that more data was coming into the SX than going out towards the PC. The communication to the PC appears to be working right, I switched the logic and it seemed to talk to my software OK. But listen(directed to everyone) --- I now have 3 or 4 programs written by different people. And I appreciate it. But here's the problem: there are like 4792384 different approaches, and everyone is taking a slightly different one. I rewrote Guenther's code in SX/B, but that has yet to pan out. I'm sure it's my fault --- I mean it's my code that's the problem. BUT --- From my original message. I have written code myself that does this already -- I've attached the latest and greatest version. My code is clean, short, and simple. and more importantly, it's WORKING. I'm probably getting about 10% of the data accurate, but the logic behind it is RIGHT. The original reason for my post was to get ideas on HOW to debug my program. I know its a timing problem. The values I guessed for the code can't possibly be right. And I have no idea why the value I picked shouldn't even work. I'm doing a [code]returnint 75[/code] which ends up producing [code] 163 0047 0CB5 MOV W,#181 164 0048 000F RETIW That. And I've tried with trial and error to adjust that 75 to lower values, and higher values. None of them produce anything even close to the same results. Is there something so fundamentally wrong with my code that I should completely switch to a different way of writing this? I've learned that writing code with two interrupt sources is harder than writing code with one. I get that. But my code is close. What I need to know is 1. Should I be clearing RTCC every time I enter my ISR? If I change it to clear only when I detect an edge with the idea to resync the rollover on an edge, this produces garbage. Should I be setting it to zero, or some other value? What value? 2. What should I be using for returnint? Or if you look at it this way, what value should W contain before RETIW? I know there should be a "calculated" value, ie look how many cycles my ISR takes, how often data comes, etc etc and then add them up and divide by PI, and then I have my number. And certainly, this will deviate from real life by a +/- 10% or something, which can be adjusted via trial and error etc. But I don't know how to go about calculating this value. I'm now using the debugger, which is a step in the right direction. But I still don't know how to leverage this to help debug my code. Thanks Keith [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=78490#m79243 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)