Hmmm... Not so good at C or BASIC coding (or whatever it is), but I think the problem might be with the second loop (that's supposedly continuous). If the second (always) loop wasn't working, the button loop might work, but the next loop only executes once, so the square wave works fine, as long as the button is held down. I usually use, instead of while(1), I use while(5==5), because I have found some compilers don't always treat ones as trues. At least with 5==5 I can be certain. Also, with the language you are using, if it reaches the end of main, does it loop back to the begining, or what? On 5/13/05, Michael Rigby-Jones wrote: > > > >-----Original Message----- > >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] > >Sent: 13 May 2005 10:15 > >To: Microcontroller discussion list - Public. > >Subject: Re: [PIC] strange problem > > > > > > > >> while(B0!=1); > > > >What is connected to the other 7 bits of PORTB ? Since your > >setting in TRISB makes them all inputs, unless they are all > >wired to 0v then the above loop will NOT wait for you to press > >the button. > > > >You probably want to test just the bottom bit like this ... > > > > while((B0 & 1) == 0) ; > > > >Peter > > I'm not familiar with the compiler (CCS?), but the syntax suggests that > the original code is a bit test on RB0 and therefore quite valid. > > To the OP: If you are certain it's not a watchdog issue, then persuade > your compiler to produce an assembly listing so you can check if the > code the compiler is producing matches your source. It's a very small > program so should be easy enough to follow. Post it to the list if it > dosen't make sense. > > Regards > > Mike > > ======================================================================= > This e-mail is intended for the person it is addressed to only. The > information contained in it may be confidential and/or protected by > law. If you are not the intended recipient of this message, you must > not make any use of this information, or copy or show it to any > person. Please contact us immediately to tell us that you have > received this e-mail, and return the original to us. Any use, > forwarding, printing or copying of this message is strictly prohibited. > No part of this message can be considered a request for goods or > services. > ======================================================================= > > -- > 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