We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I use int0 & int1 to measure the width of a pulse. My program works fine in the simulator with inputs from an include file. When I run the program on a breadboard using an ATMEL AT89C1051 I do not get a response to the external interrupt inputs. I can see these strobes with a 'scope. I have put p1.x toggles in the two isr's involved and do not see any toggling. In my init part of the program I do select edge triggering, int0 & int1 enabled, master interrupt enabled. Does anyone know what more must be done for this mode of operation? - ATMEL chip, A51 assembler, external interrupts.
I have copied and pasted the interrupt initialization and isr routines into this message. NAME Electronic_Servo_Controller ORG 60H ; stack origin stack: DS 10H ; stack depth throttle: DS 1 throttle_low: DS 1 throttle_high: DS 1 scaled_throttle: DS 1 BSEG throttle_low_flag: DBIT 1 throttle_calibrated_flag: DBIT 1 power_on: DBIT 1 ; *************************************************************** ; Purpose: ; Interrupt vector definitions. ; *************************************************************** CSEG ORG 0000H ; Power on/reset vector ljmp pwr_on_reset ljmp throttle_start_isr ; Start timer 1 ORG 0013H ; external interrupt 1 vector ljmp throttle_stop_isr ; Stop timer 1 ; *************************************************************** ; Purpose: ; Power on Reset interrupt function. ; *************************************************************** ORG 0080H ; begin code space USING 0 ; register bank zero pwr_on_reset: mov sp, #(stack-1) ; initialize stack pointer setb IT0 ; INT0 edge triggered, clr'ed by h'ware setb IT1 ; Ditto for INT1 setb EX0 ; Enable INT0 setb EX1 setb EA ; Enable ALL interrupts setb p3.2 ; Configure INT0 pin for input setb p3.3 mov TMOD,#00010000b ; Timer 1 on mov TL1,#0 mov TH1,#0 clr throttle_low_flag clr throttle_calibrated_flag mov r2,#0 ;strobe count=0 strobe: jb throttle_calibrated_flag,make_waves cpl p1.2 ;In calibrate loop call calibrate jmp strobe make_waves: call measure cpl p1.3 ;After measure call pwm cpl p1.4 ;After pwm jmp strobe ; *************************************************************** ; Purpose: ; Interrupt service routine for start of throttle strobe from R/C RX. ; Outputs: ; EX0 ... External interrupt 0 flag ; TR1 ... Timer 1 on/off switch ; *************************************************************** throttle_start_isr: cpl p1.5 setb TR1 ; Start timer 1 RETI ; *************************************************************** ; Purpose: ; Interrupt service routine for end of throttle strobe from R/C RX. ; Inputs: ; TH1 ... High byte of timer 1 ; Outputs: ; EX0 ... External interrupt 0 flag ; EX1 ... External interrupt 1 flag ; TR1 ... Timer 1 on/off switch ; TH1 ... High byte of timer 1 ; b ..... shift count ; r2 .... throttle strobe counter ; Routines called ; shl_n ... multiple shift left ; *************************************************************** throttle_stop_isr: cpl p1.6 clr TR1 ; Stop timer 1 mov b,#5 ; Shift left count anl TH1,#00000111b ; Mask high byte of timer 1 call shl_n ; Use max resolution for 1 byte inc r2 cjne r2,#250,clear_timer1 sjmp no_clear clear_timer1: mov r0,#throttle mov @r0,TH1 mov TL1,#0 mov TH1,#0 no_clear: RETI