Bob Ammerman wrote: >----- Original Message ----- >From: Dan Michaels > >> Hi Tony, I think this is not exactly correct. If you only exercise >> a single pin uisng BSF/BCF, it will work correctly, but if you do >> successive BSF/BCFs to > 1 PortA pins, then only the last will be >> operated upon corrrectly, and all others will always end up being >> cleared. >> >> BSF PORTA, 0 >> BSF PORTA, 1 >> BSF PORTA, 2 >> >> will leave the port in the following state: xxxx'x100 >> >> [either that or it's naptime]. >> > >Dan, > >Right: > >Given A,0 A,1 and A,2 defined as analog and as output: > >BSF PORTA,0 will SET A.0 and CLEAR A.1 and A.2 >BSF PORTA,1 will SET A.1 and CLEAR A.0 and A.2 >BSF PORTA,2 will SET A.2 and CLEAR A.0 and A.1 > >So, when you are done you will indeed end up with a zero on A.0 and A.1, but >there will have been a nice pulse of 1 in the meanwhile. > Well Bob, that's 2 of us who seem to agree on this, although AndyW saw it differently. Hmmm, which gets me to thinking - ie, Mchp built some damn many "gotchas" into these thingies that piclist can support 1800 "experts" each with a totally different set of experiences <:-))). ================== >Now that gets me to thinking: Here is a neat trick to get a 'push-pull' >output from two PORT A pins: > >1: define them as analog (ADCON1) >2: TRIS them as outputs. > >Now, when you BSF either of them the other will automatically be cleared. > >This would have been useful in a system I built that drove a piezo >transducer directly off two PIC pins. > Guess you could always write xxxx'xx01 and xxxx'xx10, on regular digital pins. And actually, you can drive a piezo quite well using a single pin on a PIC. In fact, as it is, you normally have to use a 100-1000 ohm attenuation R in series, or it will drive you right out of the room. - danM -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.