rumpelteazer666 wrote: > nothing yet. I substituted TRISB=255; with TRISB=1; (setting as input only > the last bit), and put a 220ohm resistor between PORTB0 and ground. The i > use a clip to connect the 5V to PORTB0 and it plays, i disconnect the clip > and it stops again until i connect it again. 220ohm seems too low to me. 10K is what I use for pull-up/down. Maybe the switching causes a glitch and resets the PIC? Make sure your circuit is OK. You should have capacitors next+ to the supply pins. Tie MCLR to VCC with a 10K resistor or so. Tie unused pins either high or low (you shouldn't need a resistor since pins are supposed to startup as inputs and nothing should happen due to a direct connection, but you might want to use resistors to prevent a software bug that sets them as outputs from blowing your pins). Also make sure you are connecting your output properly to your amp. Direct connection to a low impedance input may not be a good idea, you might want to try capacitor coupling it to a small speaker which is usually OK for testing. Wire a standard 8ohm small speaker in series with a 1uF capacitor, from PIC pin to ground. Also you shouldn't just let the program "hang off" the end, even if there is an infinite loop. Set something notable there, say set some other output pin and wait 1 second. Then you can watch for that behaviour. Add a delay at the beginning of the program. Set all output pins low by default, then wait and set one of them high. wait and set another one high and unset the first one. Wait for a button press, once pressed set both and begin the squarewave loop. That should give you an idea of what happens by connecting 2 LEDs to the pins (through a 1k resistor of course.) Oh, a thought. That is pin RB0/INT. Maybe you've got interrupts enabled for INT input? That could potentially trigger an interrupt on either the rising or falling edge and jump to position 0x4 in program space, quite probably restarting the program (which usually begins at position 0x5 with a jump at 0x0 or so). Setting INTCON=0 should kill all interrupts Another thing: > _asm > movlw _a > movwf _d1 > Delay_0: > decfsz _d1, f > goto Delay_0 > nop > nop > > _endasm; That seems wrong to me. I haven't worked with C compilers but _a should be a *register* or RAM location, NOT a literal value. So not "movlw _a", but "movf _a,w". I think. You can also just use a constant with movlw, but I'm guessing you would want to vary the frequency in the future using 'a'. I think something is quickly resetting the PIC, and instead of the delay frequency you are really experiencing startup delays (since your delay function looks nonfunctional due to the aforementioned detail) which produce the output squarewave. Greets, -- Hector Martin (hector@marcansoft.com) Public Key: http://www.marcansoft.com/hector.asc -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist