Need help on SX Interrupts.
achidichi
Posts: 5
Hi:
Reading the SX20/28 and SX48/52 datasheets I found some differences related with interrupts topic.
The SX20/28 datasheet talks about 'missing the interrupt trigger at MIWU port' if these port interrupts are not 'disabled' when entering the ISR.
On the other hand, the SX48/52 datasheet talks nothing about 'triggers', it just says that interrupts will be executing again and again as long as there are pending bits on the MIWU port. I guess this last explanation makes more sense than previous one on the SX20/28 docs.
So, are they really a little bit different? Please advice.
Reading the SX20/28 and SX48/52 datasheets I found some differences related with interrupts topic.
The SX20/28 datasheet talks about 'missing the interrupt trigger at MIWU port' if these port interrupts are not 'disabled' when entering the ISR.
On the other hand, the SX48/52 datasheet talks nothing about 'triggers', it just says that interrupts will be executing again and again as long as there are pending bits on the MIWU port. I guess this last explanation makes more sense than previous one on the SX20/28 docs.
So, are they really a little bit different? Please advice.
Comments
Mike,
Has the SX forum been shut down?
If so. how did achidichi get a post in there, where I can not post a new thread?
The WKPND_B register exists on both the 20/28 and 48/52, but the 48/52 also has timer interrupt bits that need to be read/reset if needed.
1) So, the SX48/52 datasheet is right? As long as there are pending bits the ISR will be called and execute?.
As I told before, despite this reasonable logic, the SX20/28 datasheet suggests that in spite of these enabled pending bits (by external edges) there could be no interrupt callings (triggers) if they were activated while WKEN_B was enabled inside the ISR. This just makes me crazy.... I copy & paste the text from the datasheet I refer to:
"If an external interrupt occurs during the interrupt routine, the pending register will be updated but the trigger will be ignored unless interrupts are disabled at the beginning of the interrupt routine and enabled again at the end. This also requires that the new interrupt does not occur before interrupts are disabled in the interrupt routine. If there is a possibility of additional interrupts occurring before they can be disabled, the device will miss those interrupt triggers."
2) I am afraid I could loose some interrupts. I have 2 external edge sources I want to process asynchronously. I cannot afford to miss one (both edge sources are unrelated).
I know I could use some other tools like an FPGA but I know this simple task is a piece of cake with microcontrollers, right? The time interval between 2 edges on the same pin is big. But as they are unrelated they can appear at the same time on both pins.
Please advice on 1) and 2).
The main diagrams are not 100% right either.
The simplest explaining is that there are more sources for interrupts available in the SX48/52, but there is only one ISR vector regardless.
To make matters more complicated, if you intend to use the Sleep and Wake up features, there is another layer of complexity.
I actually turned to similar PIC chips to find a better explanation of the interrupts and the WakeUp/Sleep feature. The two additional timers on the SX48-52 are the main source of additional interrupt triggers. It seems that more than one trigger might be able to be available at the same time, but that is a nightmarish scenario.
I've spent a lot of time in the past trying to comprehend this. May be too much time. It take a lot of reading and rereading to get a true image of what is going on. I think I've done so, but haven't bothered to put it in any form that can be shared with others.
What is the fastest possible time your pins will trigger? If it were my project, I would abandon triggered interrupts per se, and just use an RTCC rollover ISR running a minimum of 2-4 times faster than my possible fastest pin change (or much, much faster if I need more precise time count units between pin state changes). Then I could poll as many pins and their states as I need to in the ISR, update a few counter registers, and not have to deal with missed WKEN/WKPEND bits.
The idea is that you run the ISR often enough that you can't possibly miss a pin state change on the pins you are sampling.
You have to run down all the sections and diagrams that apply and read and re-read everything to grasp what is really going on. I've done this at least five or six times and I kept learning more. It is much easier if you have a goal and want to be sure you are getting the results you desire. It is harder to just read it all for 'a comprehensive understanding' of the SXes.
And it never hurts to create and run some tests, observe the results, and compare them against your expectations.
ISRs with the Sleep/WakeUp enabled behave differently than ISRs without this feature.
Yes, I will run some test programs to discard or accept facts explained in datasheets.
Since it is an EOL product and thread is now archived, nobody is going to revise the resources available.
You might find somebody at www.sxlist.com that is still sharing their knowledge. Similar PIC chips do help as the SXes were intended to be compatible replacement parts.
I didn't have time to test it yet but reading the datasheet more carefully regarding this MIWU port, I realized that they must be right about missing some interrupts. That is because of the 'exchange' instruction:
mov M, #$09;
clr W;
mov !RB, W
which can collide with the arriving of a new detected edge. Yes, your clearing of 'one' pending bit can erase a new detected edge on the rest of the pins if they happen to be at the same time. That is the real flaw on the machine here!!!. Why didn't they do it a 'bit addresable' port to avoid this messing? I don't know !!!
I will use the sampling scheme as suggested by the documentation and Zoot.
I've not worked with the SX, so I am not familiar with whatever development or debugging software is available...
But with other chips, where I did not understand exactly what the documentation was saying, I would do whatever it took to "SEE" what was happening.
In some cases I can write a test program to turn on an LED if such and so happens. (Or display "I was here" on a monitor if the program takes a certain path- whatever.)
Of if "fancy" debugging software is available, I may be able to slowly step through a program and watch registers for bits being set or not or see if the program takes a certain path.
Also with an external or debugging software logic analyzer, you can "see" what is going on (or not going on!)
And that is the trick to understanding or troubleshooting something. If you can see what is happening, then all is suddenly clear as light!