??? 01/07/06 16:55 Read: times |
#106787 - Timer 2 capture interrupt |
Hi there,
I have finally managed to successfully upload a HEX file onto an AT89S8252 using SP89, but now I am having difficulties with the timer 2 capture interrupt. The following code was made just to see if I could get the interrupt to work, but it won't. Initial: LJMP Start ORG 0034h Start: MOV T2CON, #0Dh ;Setup timer 2 SETB EA ;Enable interrupts SETB ET2 ;Enable timer 2 interrupt EN EQU P3.3 RW EQU P3.4 RS EQU P3.5 DATA EQU P2 INIT_LCD: MOV A, #38h LCALL LCD_COMMAND MOV A, #0Eh LCALL LCD_COMMAND MOV A, #06h LCALL LCD_COMMAND LCALL CLEAR_LCD MOV A, #'A' LCALL LCD_WRITE MOV A, #'B' LCALL LCD_WRITE MOV A, #'C' LCALL LCD_WRITE MOV A, #':' LCALL LCD_WRITE Mainloop: ; Writing numbers to the LCD MOV A, #85h LCALL LCD_COMMAND MOV A, #01h ADD A, #30h LCALL LCD_WRITE MOV A, #02h ADD A, #30h LCALL LCD_WRITE MOV A, #03h ADD A, #30h LCALL LCD_WRITE MOV A, #04h ADD A, #30h LCALL LCD_WRITE MOV A, #05h ADD A, #30h LCALL LCD_WRITE LJMP Mainloop ;Interrupts ORG 002Bh LCALL Overflow_int RETI ORG 0FAh Overflow_int: JNB TF2, Capture_int CLR TF2 RET Capture_int: CLR EXF2 PUSH ACC MOV A, #0C0h LCALL LCD_COMMAND MOV A, #03h ADD A, #30h LCALL LCD_WRITE MOV A, #03h ADD A, #30h LCALL LCD_WRITE MOV A, #03h ADD A, #30h LCALL LCD_WRITE POP ACC RET ;Subroutines LCD_COMMAND: CLR RS CLR RW MOV DATA, A SETB EN NOP NOP NOP NOP CLR EN LCALL WAIT_LCD RET WAIT_LCD: CLR RS SETB RW MOV DATA, #0FFh SETB EN MOV A, DATA JB ACC.7, WAIT_LCD CLR EN CLR RW RET CLEAR_LCD: MOV A, #01h LCALL LCD_COMMAND RET LCD_WRITE: SETB RS CLR RW MOV DATA, A SETB EN NOP NOP NOP NOP CLR EN LCALL WAIT_LCD RET END All this code is meant to do is display 'ABC: 12345' on the top line of the display permanently and then '333' on the bottom line of the display when the timer 2 interrupt is caused by a 1-0 transition on P1.1, which means that EXF2 flag must be set. When I use the simulator that is built into Pinnacle 52, the timer 2 interrupt is always called when the TF2 flag is set due to timer 2 overflowing - this is correct. However, when I play around with P1.1 (T2EX) in the ports window, it never triggers an interrupt, which is what I need it to do. I have also put this program onto the actual MCU and tried to get it to display '333' but it won't trigger the interrupt. I get the 'ABC: 12345' to work properly, but no interrupt. Can anyone see any obvious flaws in my program? The MCU is an AT89S8252. Regards Warren BTW, the obove section of program was made purely to test this interrupt and is a modified section from another program , so if it seems a bit cumbersome and strange, that is the reason... |
Topic | Author | Date |
Timer 2 capture interrupt | 01/01/70 00:00 | |
To Start | 01/01/70 00:00 | |
Oh dear... | 01/01/70 00:00 | |
PRE![]() | 01/01/70 00:00 |