1
\$\begingroup\$

I am using the PIC16F876 to program an AD9833. I am using the RA2 pin for FSYNC, RA3 pin for SCLK and RA4 pin for SDATA. I have used ADCON1 = 0x07 to set all the A ports as digital and PORTA = 0x00 to set all the ports as outputs.

The problem is that the RA4 pin is not responding to commands. I know this is a special pin but I think it can be used as a digital I/O.

Can someone tell me what I am missing? I assume there is another register write which enables RA4 as a standard digital I/O but I can't seem to find it.

\$\endgroup\$
  • \$\begingroup\$ I have found out that I cannot drive this pin high, it needs an external pull up resistor. But if anyone can shed more light on this is would still appreciate it. \$\endgroup\$ – Tim Mottram Jul 1 '13 at 15:48
  • \$\begingroup\$ Can you confirm that the microcontroller is on, can you toggle an LED with any pin? \$\endgroup\$ – Iancovici Jul 1 '13 at 15:49
  • \$\begingroup\$ It clearly states in the documentation that RA4 is an open drain type - RTFM (page 7) \$\endgroup\$ – JIm Dearden Jul 1 '13 at 15:51
  • \$\begingroup\$ Yes this PIC works fine. All other Pins work OK. I was not familiar with the open drain type pins. Do I just connect it to 5v through a resistor? (leaving the connection to the SDATA pin on the AD9833 as it is?) \$\endgroup\$ – Tim Mottram Jul 1 '13 at 15:54
3
\$\begingroup\$

The RA4 pin is open drain (when you write 0 it's connected to the ground, when you write 1 it's floating) so you need a pull-up resistor. You don't have to change your circuit, simply add a resistor between RA4 and Vcc (in your case 5 V). You can use a standard 10 kΩ resistor (that is usually great), lower values like 4.7 kΩ can be used if it's necessary more speed.

\$\endgroup\$
  • \$\begingroup\$ Nooo.. It's been driving me crackers for a week now! Thank you, Guru. \$\endgroup\$ – user70039 Mar 15 '15 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.