In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Staryi wrote: Bean, I find the interesting thing. This bug is occurs only at 20 MHz and lower! On 50 or 40 Mhz this bug not detected. On 30 - sometimes. On 20 and lower - always! This is one more version of bug demo program. It counts errors, and shows errcnt on RA.(0..3). [code] ; Demonstrate the inc/dec bug without debugger (next version) ; Need 4 LED connected from RA.(0..3) to GND ; (whis current limiter resistor, of course) ; When right work, LEDs don't light ; When this bug occur, the LEDs shows 4 bits of error counter ; Use internal clock oscillator at 32 kHz. DEVICE SX48,OSC32KHZ ;DEVICE SX48,OSCHS3 ;FREQ 20000000 ; May be any from 32 kHz up to 20 MHz - uncomment if work with debugger IRC_CAL IRC_SLOW RESET start org 0x0a count1 ds 1 ; Two counters count2 ds 1 ; errcnt ds 1 ; error counter org 0 ; Interrupt service routine (very dummy) reti start page main jmp main main mov W,#0x1f ; DDIR_W mode mov M,W ; Mov !RA,#11110000b ; RA.(0..3) for output clr errcnt ; errcnt = 0 Mov RTCC,#0 Mov !option,#10001000b ; RTCC start jmp @Work org 0x800 ; Critically routine Work clr count1 ; count1 = count2 = 0 clr count2 ; :loop inc count1 ; Counters increment inc count2 ; ;if is no bug, count1 and count2 must be equal here nop ; for odd loop clocks (9) mov W,count1 ; Compare counters xor W,count2 ; snz ; jmp :loop ; Infinite loop if equal inc errcnt ; if not - count errors Mov RA,errcnt ; Show errcnt jmp Work ; Repeat end [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=146451#m146603 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)