??? 01/05/05 22:05 Read: times |
#84420 - Optimizing ISR |
Dear all members,
I have this piece of code in assembly which is an ISR. If I'm not mistaken then it take approximatelly 282us to complet the task at 12MHz sysclk. However I'd like to make it faster but still preserve the functionality (in this case generating a chain of 5 firing pulses precisely 30us on and 20us off). Is there any other approachs that can optimize this to make it faster and take less MCU resource? The reason I'm asking because I'm experiencing some sort of problem as "missed-firing" in an application where I need to control 2 pair of SCRs. It only occurs when I run both pair at the same time, and only miss firing on second pair.If I run one pair at the time then it's OK. I think the ISR take too long so the control loops miss something The device is 87C552 but I'm running Emulator now. I use only Bank 0 and ISRs don't do any thing that related to ACC or PSW, so I don't use PUSH and POP inst. I use Timer 2 CT0 for Phase detect, and CM0, CM1 for generating firing pulses Here is the ISRs: COM0: MOV 44H,#05H ; 1 CONY1: SETB P4.0 ; 1 - Pulses on MOV 45H,#0FH ; 1 DJNZ 45H,$ ; 2 x 15 = 30us CLR P4.0 ; 1 - Pulses off MOV 46H,#0AH ; 1 DJNZ 46H,$ ; 2 x 10 = 20us DJNZ 44H,CONY1 ; (5 x 54) + (2 x 5) = 280us CLR TM2IR.4 ; 1 RETI ; Total = 282us COM1: MOV 47H,#05H ; Load ram @47H with 5 Hex CONY2: SETB P4.1 ; Pulses on MOV 48H,#15 ; Load ram @48H with 15 DJNZ 48H,$ ; Loop here 15 times CLR P4.1 ; Pulses off MOV 49H,#10 ; Load ram @49H with 10 DJNZ 49H,$ ; Loop here 10 times DJNZ 47H,CONY2 ; Loop back CLR TM2IR.5 ; Enable interrupt CM1 RETI ; Return from interrupt And here is the config of my SCRs: X----------------------------X X----------| INDUCTIVE LOAD - FIELD A |--------(+)------------------(+) | X ---------------------------X | | ||X~~~~~~~~(AC1)200Vac | | | (X)~~~~X||C | | | C||C | | / | / C||C | ------- ------- C||C | / / C||C | /A 1 /A 2 C||C 0Vac | ------- ------- 480Vac C||X~~~~~~~~~~~~~~~~~~~~~~X | | C||C | | | C||C | | | C||C | | | C||C | (AC1) (AC2) C||C | | | C||C | | | (X)~~~~X||C | | | ||C~~~~~~~~(AC2)200Vac | | / | / | ------- ------- | / / | /B 1 /B 2 | ------- ------- | | | | | | | | | | X ---------------------------X | | X----------| INDUCTIVE LOAD - FIELD B |--------(-)------------------(-) X ---------------------------X This is Dual config and firing sequence will be A1 and A2 on for motor A and/or B1 and B2 on for motor B Any input/suggestions would be greatly appreciated. Regards, T.L |
Topic | Author | Date |
Optimizing ISR | 01/01/70 00:00 | |
Delay loop inside ISR=no-no | 01/01/70 00:00 | |
Delay in ISR | 01/01/70 00:00 | |
re-sched ISR | 01/01/70 00:00 | |
Timing ISR | 01/01/70 00:00 | |
ISR | 01/01/70 00:00 | |
More thoughts | 01/01/70 00:00 | |
More thought | 01/01/70 00:00 | |
how about a PCA | 01/01/70 00:00 | |
how about a PCA![]() | 01/01/70 00:00 |