Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/27/04 19:25
Read: times


 
#69337 - need help with tutorial
TCOUNT EQU 40h ;This is an address in IRAM

ORG 0000h
LJMP MAIN

ORG 000Bh
T0_INTERRUPT:
MOV TL0,#0B0h ;Set TL0 to 0B0h
MOV TH0,#3Ch ;Set TH0 to 3Ch
DJNZ TCOUNT,T0_EXIT ;Decrement TCOUNT, if not zero exit interrupt
setb p2.2 ;Set ALARM to indicate the preset time has passed

T0_EXIT:
RETI ;Return from the interrupt

MAIN:
MOV TMOD,#01h ;Set timer 0 to 16-bit mode
MOV TH0,#03Ch ;Initialize TH0 to overflow every .05 seconds
MOV TL0,#0B0h ;Initialize TL0 to overflow every .05 seconds
clr p2.2
SETB ET0 ;Enable timer interrupt 0
SETB EA ;Enable all interrupts

MOV TCOUNT,#20 ;Set TCOUNT to 20 to wait for 1 second
SETB TR0 ;Turn timer 0 on
JNB p2.2,$ ;Cycle until ALARM is set (1 second later)
end

i'm learning the 8051 tutorial. i hope u guys can help me out . i copied this code from the tutorial section.i modified abit so that it will setb p2.2 after 1s. i tried to compile and run it on a 8052 simulator and found that the process stop at the JNB p2.2,$. it just wont setb p2.2 after a few seconds i waited.
any 1 know what's wrong with the code?

List of 12 messages in thread
TopicAuthorDate
need help with tutorial            01/01/70 00:00      
   RE: need help with tutorial            01/01/70 00:00      
   RE: need help with tutorial            01/01/70 00:00      
      RE: need help with tutorial            01/01/70 00:00      
   RE: need help with tutorial            01/01/70 00:00      
      RE: need help with tutorial            01/01/70 00:00      
      RE: need help with tutorial            01/01/70 00:00      
   RE: need help with tutorial            01/01/70 00:00      
      RE: need help with tutorial            01/01/70 00:00      
   RE: need help with tutorial            01/01/70 00:00      
      RE: need help with tutorial            01/01/70 00:00      
         Slip of the pen            01/01/70 00:00      

Back to Subject List