| ??? 10/21/11 00:36 Read: times | #184293 - Rewrote Source Code for Metalink Assembler Responding to: ???'s previous message | 
| Maunik Choksi said: 
        .equ    OUTPIN,P2.1
        .equ    basecount,021h
          .org  0000h
          SJMP  MAIN
          .org  000bh           ;Use timer0
          LJMP  TIMER_ROUT
          .org  0070h
MAIN:     MOV   SP,#050H
          MOV   TMOD,#01H       ;initialise timer 0 in 16 bit mode
          mov   IP,#02h         ;give priority to timer0
          mov   TH0,#0ech       ;5ms timer count loaded
          mov   TL0,#078h       ;for 12 Mhz crystal
          ;The formula for deciding count is like
          ;(65535 - 5000) = 60535 here 5000 count for 5ms timer
          ;if you want to generate 1 ms timer then your formula should be
          ;(65525 - 1000) = 64535 and so on.
          ;So here we get count for 5ms timer = 60535D = EC78H =TH0TL0
          setb  TR0             ;turns on timer0
main1:
          MOV   IE,#082H        ;1000 0010 Enables timer0 interrupt
          sjmp  main1
TIMER_ROUT:
;After Every 5ms time the timer interrupt jumps here
          mov   TH0,#0ech       ;Reload timer count
          mov   TL0,#078h
          inc   basecount
          mov   a,basecount
          cjne  a,#50,skipchangestatus  
          cpl   OUTPIN          ;after every 50 * 5 = 250 ms compliment the OutputPin status
                                ;So you get 2 low 2 high output status in 1 sec i.e 2 Hz freq.
          mov   basecount,#0    ;reset the base count
skipchangestatus:
          reti                  ;return from timer interrupt
Hi Maunik: Can you tell me the type of assembler you used to compile your source code. I would have gotten back to you sooner but my assembler software had to be changed to match my win7 64bit system and I only rec. software now. I also had problem with my programmer again to do with win7 64bit system. Now that I had both working I reassembled your source code to my metalinek assembler and after some small changes got it to assemble hex file and list file with no errors. I now have to test it in my sbc 89c2051 for this chip. Thanks for all the help and will upload picture of the functional use when it fully works. But I still would like to know the name of your assembler? Best regards, Ralph Sac | 




