title: 8051 Timers + Interrupts
body: <p>I am new to working assembly code and I am trying to make a program that will read in values from ROM and depending on what values they are play a certain note for a certain length of time.  The code itself compiles just fine, but when I go to send the code to the 8051, nothing happens.  I think I have the timers setup properly (along with their individual interrupts); however, I am by no means an expert.  And the code doesn't do much right now, it's suppose to just play one note over and over again forever, but nothing happens...  The actual chip is 89LPC932A1 and here is a user manual: <a href="http://www.nxp.com/documents/user_manual/UM10109.pdf" rel="nofollow">http://www.nxp.com/documents/user_manual/UM10109.pdf</a></p>
  
  <p>Here is the code:</p>
  
  <pre><code>#include &lt;reg932.inc&gt;
  
          NOTE_LENGTH EQU R0
          HIGH_CURRENT_NOTE EQU R1
          LOW_CURRENT_NOTE EQU R2
          TEMP EQU R3
          HIGH_NOTE_LENGTH EQU R4
          LOW_NOTE_LENGTH EQU R5
          DPTR_VALUE EQU R6
  
  
  
          ORG 0
          LJMP SETUP
  
          ORG 000BH
  TIMER0:     CPL P1.7
          MOV TH0, HIGH_CURRENT_NOTE
          MOV TL0, LOW_CURRENT_NOTE
          RETI
  
          ORG 001BH
  TIMER1:     CJNE NOTE_LENGTH, #0, TIMER1_END
          SETB TR0                                
          MOV TEMP, A
          MOV DPTR, #SONG
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV HIGH_CURRENT_NOTE, A
          INC DPTR_VALUE
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV LOW_CURRENT_NOTE, A
          INC DPTR_VALUE
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV NOTE_LENGTH, A
          INC DPTR_VALUE
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV HIGH_NOTE_LENGTH, A
          INC DPTR_VALUE
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV LOW_NOTE_LENGTH, A
          INC DPTR_VALUE
  
          MOV A, TEMP
          MOV DPTR_VALUE, #0
          CLR TR0                         
          RETI
  
  TIMER1_END: DEC NOTE_LENGTH
          RETI
  
  
          ORG 0080H
  SETUP:      MOV DPTR, #SONG
          MOV DPTR_VALUE, #0
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV HIGH_CURRENT_NOTE, A
          INC DPTR_VALUE
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV LOW_CURRENT_NOTE, A
          INC DPTR_VALUE
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV NOTE_LENGTH, A
          INC DPTR_VALUE
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV HIGH_NOTE_LENGTH, A
          INC DPTR_VALUE
  
          MOV A, DPTR_VALUE
          MOVC A, @A+DPTR
          MOV LOW_NOTE_LENGTH, A
          INC DPTR_VALUE
  
          MOV IEN0, #0x88
          MOV TMOD, #0x11
          SETB TR1
          SETB TR0
  
  MAIN:       SJMP $
  
          ORG 0F00H
  SONG:       DB  80H, 80H, 26, 0, 0
  
          END
  </code></pre>