| ??? 02/11/03 00:45 Read: times |
#38749 - Actual Code for a 1 Sec ISR Responding to: ???'s previous message |
Dear Waqar,
I have given a simple coding that will just toggle a port pin P1.1 every 1 sec. For a start you can easily observe the voltage on a DMM or if you are comfortable with hardware connect a transistor driven LED to this port. This compiles fine on a Pinnacle IDE. Use this as a base and take up the delay to 1 minute - very easy hoemwork. I have copied from my general routines and assembled this for you - it should run without bugs. The commenting is bit too much - once again for your benefit. Maybe you cannot see the tab alignments in this post - but cut and copy the coding into any assembler and they should appear. Let me know if you run into problems. ; ISR DEMO PROGRAM for a 80c52 MCU ; CONSTANT declarations :====================== T0_VAL EQU 250 ; 250 microsec for Timer 0 TIME1 EQU 40 ; No of loops for COUNT1 TIME2 EQU 100 ; No of loops for COUNT2 ; T0_VAL x TIME1 x TIME2 = 1 Sec ORG 20H COUNT1 DS 1 ; RAM loactions defined COUNT2 DS 1 ; Main Program starts here:====================== ORG 0000H LJMP INITPGM ORG 000BH ; TF0 interrupt vector LJMP ONESEC ; Interrupt service routine address ORG 100H INITPGM: ;MOV AUXR, #02H ; For access to ERAM with RD2 chips only MOV SP, #80H ; Stack will use indirect RAM MOV TH0, #256-T0_VAL ; Interrupt every 250 microsecs... MOV TL0, #256-T0_VAL MOV TMOD, #022H ; Timer in Auto Reload mode MOV COUNT1, #TIME1 ; Preset counters MOV COUNT2, #TIME2 SETB TCON.4 ; Start Timer 0 SETB IE.1 SETB IE.7 ; Enable interrupts CLR P1.1 ; I assume that your output port is P1.1. Change if not.... MAIN: SJMP $ ; Just loop here doing only the ISR. ; Interrupt service routine ( ISR )==================== ONESEC: PUSH PSW ; Save keys registers.... PUSH ACC SETB PSW.3 ; Save the Bank 0 registers PROCED1: DJNZ COUNT1, EXIT ; 40 interrupts over ? Exit if not. MOV COUNT1, #TIME1 ; Yes . Reload DJNZ COUNT2, EXIT ; 40 X 100 interrupts over ? Exit if not. MOV COUNT2, #TIME2 ; Yes. Reload CPL P1.1 ; 1 Sec over. Change output EXIT: CLR PSW.3 POP ACC ; Return from interrupt after restoring saved SFRs POP PSW RETI END |
| Topic | Author | Date |
| flow charts for digital clock | 01/01/70 00:00 | |
| RE: flow charts for digital clock | 01/01/70 00:00 | |
| RE: flow charts for digital clock | 01/01/70 00:00 | |
| RE: flow charts for digital clock | 01/01/70 00:00 | |
| please just tell me how to do this | 01/01/70 00:00 | |
| RE: please just tell me how to do this | 01/01/70 00:00 | |
| Actual Code for a 1 Sec ISR | 01/01/70 00:00 | |
RE: Actual Code for a 1 Sec ISR | 01/01/70 00:00 | |
| RE: flow charts for digital clock | 01/01/70 00:00 | |
| RE: Actual 1 sec. code: Raghunathan R | 01/01/70 00:00 | |
| RE: Actual 1 sec. code: Raghunathan R | 01/01/70 00:00 |



