| ??? 03/27/02 02:21 Read: times |
#21181 - Help me understand Serial interrupt? |
Hello,
I have run across what I consider odd behavior in the operation of the serial interrupt. I am using serial communications to link master and slave controllers. The system uses mode 2 in networked configuration until a slave recognizes its address then SM2 is cleared to receive a number of parameters from the master. Overall this functions. I use: a) R0 as a pointer to an array of parameters b) R2 as a counter to show how many times the RI/TI interrupt vector was accessed c) GetInp as a flag to show that my program has to "get input" while it is doing other things (a hold over from the master's external interrupt ISR) 1. When I use the following code: ;R1/T1 (Serial interrupt) org 23h+ProgOff jnb RI,RITI1 setb GetInp inc R2 ;interrupt counter RITI1: reti ;Data handling routine: RxP1: jnb GetInp,RxP1 mov @R0,SBUF clr GetInp clr RI inc R0 RxP2: jnb GetInp,RxP2 mov @R0,SBUF clr GetInp clr RI inc R0 ;The program receives more parameters and goes on... I see the following problems: a) The interrupt counter (R2) can be ANY value (such as 0aeh or 16h) when I run my program with a breakpoint within the RxPX portion of the code even though it is supposed to increment only when the interrupt is generated and RI is cleared after the data is moved to the array pointed to by R0 b) the array pointed to by R0 can contain multiples of the same data. For example: addresses 37h and 38h will have 0f0h; addresses 39h and 3ah will have 0d0h when 37h should have 0f0h and 38h should have 0d0h. 2. When I use the following code: ;R1/T1 (Serial int) org 23h+ProgOff jnb RI,RITI1 setb GetInp clr RI inc R2 RITI1: reti ;Data handling routine RxP1: jnb GetInp,RxP1 mov @R0,SBUF clr GetInp inc R0 RxP2: jnb GetInp,RxP2 mov @R0,SBUF clr GetInp inc R0 ;The program receives more parameters and goes on... a) R2 equals the correct count (as many times as the ISR is actually accessed). b)the parameters are stored in their proper location with no duplication. The only difference is that in the code that functions RI is cleared in the ISR. Can anyone explain what is happening with the ISR that would produce the errant results when RI is cleared after the program discovers GetInp is set by the ISR (both RI and GetInp are cleared simultaneously) versus when RI is cleared within the ISR? I would think that RI would be cleared properly for both instances but it certainly doesn't appear so. It appears that my problem code vectors to the RI/TI ISR over and over. Most code snipets I find show a loop such as: Loop: jnb RI,Loop clr RI which I think would produce code that doesn't work as desired (like my problem code), but since it is all over I assume it does work. Thanks in advance for any understanding thrown my way. Jeff |
| Topic | Author | Date |
| Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| Thanks and one more thing | 01/01/70 00:00 | |
| RE: Thanks and one more thing | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
RE: Help me understand Serial interrupt? | 01/01/70 00:00 |



