In SX Microcontrollers, SX/B Compiler and SX-Key Tool, hainguyen51 wrote: Hi Bean, Would you please to take a look for me to find out why once in a while I have an extra pulse in between the right ones. Basically, I have 1 Hz signal to rb.0, as soon as the + edge arises, I delay 2t then I have a hi pulse of 1t then goes lo. I just want to shift 1Hz signal a delay of 2t. Thanks Hai device SX28L,OSCHS3,TURBO,STACKX_OPTIONX id 'ECU103' reset start ;Jump to reset_entry on reset. FREQ 50000000 ;50MHz target frequency. ; ;Define inputs, outputs, and registers ; clock_select = RA.1 clock_pin = RB.0 mon_pin = RB.1 time1_en = RB.2 delay_count = $08 delay_count1 = $09 delay_count2 = $0A time_count = $0B loop_count = $0C ; ORG $00 ;Program start at address 00h. interrupt RETI ; start MOV M,#$0F ;Set up MODE register. MOV !RB, #$FF ;Set $00 make RB all Inputs. MOV !RC, #$00 ;Set $00 make RC all Outputs. MOV M,#$0E ;Set up MODE for PULL-UP configuration. MOV !RB, #$00 ;Set $00 make RB all inputs' Pullup. MOV !RC, #$00 ;Set $00 make RC all Outputs' Pullup. ; MOV M,#$0A MOV !RB, #$00 ;Set $00 make +slope detect at RB pins. ; MOV M,#$09 ; Prepare to use WKPND_B register MOV W,#$00 ; Assume all bits off initially MOV !RB,W ; Zero all edge detection bits ; MOV rc, #$00 MOV delay_count1,#10 ;Set delay_count1 for 3min. Sub-program. MOV delay_count2,#10 ;Set delay_count2 for 3min. Sub-program. ; main MOV !RB,W ; This will put the register bits in W TEST W ; Is W zero ? SZ ; Yes, then no edges detected, so skip SETB JMP output JMP main ; output start_delay1 MOV time_count,#40 count_loop1 CALL delay DJNZ time_count,count_loop1 ; start_delay2 MOV time_count,#20 count_loop2 SETB rc.0 CALL delay DJNZ time_count,count_loop2 CLRB rc.0 JMP main ; delay ;Long delay loop. delay1 delay2 NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP DJNZ delay_count2, delay2 DJNZ delay_count1, delay1 MOV delay_count1,#10 MOV delay_count2,#10 RET ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=302865#m302980 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)