8051 and Interrupts

Discussion in 'Programmer's Corner' started by hewitt246, Oct 18, 2009.

  1. hewitt246

    Thread Starter New Member

    Oct 1, 2009
    2
    0
    Im using the atmel 8051 chip and using keil versus 8.18 to create my program. I have been using assmebly language in order to produce my code. I wrote a program to run a string of LEDs and when the last LED is light, and interrupt is activated in order to produce an audible beep that lasts .5 seconds. I chose a 1k Hz signal that lasts roughly .7 seconds. When I run the debug in keil, the program acts if it works properly, but when i program the chip with the program it doesn't play the tone. The last LED pauses when activated, so the interrupt is actually taking place but the tone isnt played. heres my code:

    Beginning of program
    ORG 00
    LJMP INIT

    ;-Timer Interrupt 0 (INT0)-;
    ORG 0BH
    LJMP TF0ISR

    ;~Initialization~;
    INIT: MOV P0,#00H
    MOV P3,#00H
    MOV IE,#10000010B
    MOV TMOD,#0000001B

    ;~Main Program~;
    START: ACALL DELAY
    MOV P0,#00000001B
    ACALL DELAY
    MOV P0,#00000010B
    ACALL DELAY
    MOV P0,#00000100B
    ACALL DELAY
    MOV P0,#00001000B
    ACALL DELAY
    MOV P0,#00010000B
    ACALL DELAY
    MOV P0,#00100000B
    ACALL DELAY
    MOV P0,#01000000B
    ACALL DELAY
    MOV P0,#10000000B
    SETB TF0
    SJMP START

    ;~Sub-Routines~;
    DELAY: MOV R0,#06H
    TIMER: MOV TH1,#00H
    MOV TL1,#00H
    SETB TR1
    JNB TF1,$
    CLR TR1
    CLR TF1
    DJNZ R0,TIMER
    RET

    TF0ISR: MOV R1,#02H
    MOV R0,#0FFH
    TONE: SETB P3.0
    ACALL DELAY1
    CLR P3.0
    ACALL DELAY1
    DJNZ R0,TONE
    DJNZ R1,TONE
    RETI

    DELAY1: MOV TH1,#0D7H
    MOV TL1,#00H
    SETB TR1
    JNB TF1,$
    CLR TR1
    CLR TF1
    RET
     
  2. Arm_n_Legs

    Active Member

    Mar 7, 2007
    183
    10
    No where in your program starts the timer 0. Therefore, there will not be a timer 0 interrupt.
     
Loading...