I am not proud of my C skills, but until you get better advice take a hard look at that "while(B0!=1);" and see if you really can get by it without the bit button. John Ferrell http://DixieNC.US ----- Original Message ----- From: "rumpelteazer666" To: Sent: Thursday, May 12, 2005 8:27 PM Subject: [PIC] strange problem I've tried to find something useful on the datasheet,tutorials and pic books, i've tried to write it both in c and in assembler, you never know, but the problem is always there. I don't know if i can reasonably expect someone to look at the code and do the thinking for me, but this is my last hope, so i will try. The code in the while(1) block should just send a square wave to PORTA, but i put a while(B0!=1); before it. What i think it should do is, it stays still until i press the button (putting a 1 on the first bit of PORTB) and then start to play the squarewave, forgetting about the button. Well, i put it on the breadboard and i found that actually it plays the wave only as long as i keep the button pushed down. If i let a 0 on PORTB it stops again, waiting for a new 1. So somehow it goes back to the first while, how's that? :-/ ps. i know the code is useless and weird, it was a starting point to develop what i wanted to be my first pic project, but then i got blocked on my first steps by this thing. #define __16f628 #include typedef unsigned int config; config at 0x2007 __CONFIG = _HS_OSC & _WDT_OFF & _PWRTE_ON ; BIT_AT(PORTB_ADDR,0) B0; void delay(void); unsigned char a,d1; void main(void){ CMCON=7; TRISA=0; TRISB=255; a=150; PORTA=0; while(B0!=1); while(1){ PORTA=1; delay(); PORTA=255; delay(); } } void delay(void){ _asm movlw _a movwf _d1 Delay_0: decfsz _d1, f goto Delay_0 nop nop _endasm; } -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist