??? 01/10/08 14:50 Read: times |
#149221 - An alternative to your solution? Responding to: ???'s previous message |
Hi Mr.Karas,
Thanks yet again for replying. Regarding the PUSH ACC and POP ACC--note that the external interrupt and the global interrupt bit has been enabled in the last 3 lines of the following code snippet (copied from the main part of the program): N0N7: PUSH ACC MOV P1,A JNB P1.0,HERE JNB P1.1,HERE2 JNB P1.2,N5 JNB P1.3,N4 JNB P1.4,N3 JNB P1.5,N2 JNB P1.6,N1 JNB P1.7,N0 CONT: SETB P3.6 ;HIGH TO LOW PULSE TO ADC0804 WR PIN CLR P3.6 NOP NOP SETB P3.6 ;LOW TO HIGH PULSE TO ADC0804 WR PIN (START CONVERSION) MOV IE,#01H ;ENABLE EXTERNAL INTERRUPT (INT0) SETB EA ;ENABLE GLOBAL INTERRUPT BIT IN IE REGISTER (OR SFR) HERE5: CJNE R5,#0FFH,HERE5 Therefore note from the above code that the interrupts are enabled AFTER 'Nx' is sent to serial. Also I have changed the ISR to the following: ORG 0003H ;STANDARD EXTERNAL INTERRUPT INT0 ENTRY POINT EXTINT0: CLR EA ;DISABLE GLOBAL INTERRUPT BIT MOV A,P0 ;MOV 8 BIT DIGITAL VALUE FROM ADC TO ACC SETB P3.7 ;HIGH TO LOW TRANSITION TO CLR INTERRUPT LINE AND ENABLE OUTPUT LATCHES CLR P3.7 ;NOTE: P3.7 = RD PIN ON 8051 MOV R5,#0FFH RETI This should prevent any other interrupt request by the ADC to overwrite the previous value in the Accumulator Now keeping in mind the changes made to the code consider the following: N9: MOV A,#'N' CALL TX_BYTE MOV A,#'9' CALL TX_BYTE RET Since the global interrupt bit will have been already cleared when the Program Counter enters the ISR, any external interrupts will be ignored. Hence when performing the following: CJNE R0,#9,N0N7 ...and say, N0N9 hasn't been cycled 9 times by the program counter, it is impossibble that an interrupt occurs! Again, the reason being that it has been already disabled upon entering the ISR! Please do disagree with me If I am telling something wrong. Regarding the program layout, yeah I agree fully. This type of layout has been adopted after coding with C and C#. For the sake of posting on message boards I will arrange my code to a more common type of layout. I'll be arranging the N8N9 subroutine since it isn't using any form of interrupt, and I require that to ensure that a proper value is obtained from the ADC. (The ADC0804 sends a High to low signal on its INTR pin to tell the MCU That the value IS good to be sent to it). Thanks again. Kai Busuttil Industrial Electronics Student |
Topic | Author | Date |
Check my External Interrupt code | 01/01/70 00:00 | |
new question about external interrupt code | 01/01/70 00:00 | |
Scarry Type ISR Programming | 01/01/70 00:00 | |
Problem solved...almost... | 01/01/70 00:00 | |
Bogus Interrupt Usage | 01/01/70 00:00 | |
An alternative to your solution? | 01/01/70 00:00 | |
set a trap and walk right into it![]() | 01/01/70 00:00 | |
A comment on comments | 01/01/70 00:00 |