Tony Pan wrote: > > Hi all, I need help. > > I am using PIC16C73 chip. I need RA0 to be analog input but all others as > digital outputs. > > In order to have RA0 as analog input, I must set ADCON1 = 0x4 (RA0, RA1, RA3 > as analog inputs). But since I want others (RA1-RA7) to be digit outputs, I > must set TRISA = 0x1. > > But I observed that the RA1 and RA3 outputs, (which are supposed to be > analog inputs had not for the TRISA statemen,) are funny. On my board, those > two pins output pulses instead of straight lines of high or low. Other pins > (RA2, RA4-RA7) output lines -- which is correct. > > Seems to me the two statements ADCON1=0x4 and TRISA=0x1 cause confusions on > the outputs of RA1 and RA3. > > I loked up the data book of PIC16C7x. Section 13.3 "Configuring Analog Port > Pins" (Page 121) states: > > "The ADCON1, TRISA, TRISE registers control the operation of the A/D port > pins. The port pins that are desired as analog inputsmust have their > corresponding TRIS bits set (input). If the TRIS bit is cleared (output), > the digital output level (VOH or VOL) will be converted." > > > More directly, how do I set RA0 as analog input but others (RA1-RA7) as > digital output? If a pin is set as analog, but the TRIS is set as an output, when you read from the pin it will return with a zero value. If you are using BSF, BCF instructions on PORTA the analog pins will read as zero and this value will be written back to the output latch. It is better to write to a shadow register and write that value to PORTA. > Who can explain to me what the last sentence means? What does it mean by > "the digital output level (VOH or VOL) will be converted"? If you did an anlog conversion on an analog pin with the TRIS bit set as zero, the converted value will be either 0 or 255, corresponding to Logic 0 and Logic 1 which is whatever the output state is. -- Best regards Tony mICros http://www.bubblesoftonline.com mailto:sales@bubblesoftonline.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body