2
\$\begingroup\$

I have a PIC32 Ethernet Starter kit and IO expansion board. I have a made a simple input output program in which if PINC2 is high then make PINC1 high else low. I have a circuit which gives me a output voltage of 3.3v and I am applying this voltage as input to PINC2. But there is voltage problem at PINC1.

When PINC2 is low, voltage at PINC1 = 3.276v

When PINC2 is high, voltage at PINC1 = 2.8-2.9

My question is when voltage at PINC2 is low, why voltage at PINC1 is 3.276v, it should be 0volts. and when voltage at PINC2 is high, why voltage at PINC1 is 2.8-2.9v, it should be 3.276v. I am really confused at this. Please help

CODE:

int main() 
{

   TRISCbits.TRISC1=0; //output
   TRISCbits.TRISC2=1; //input
   while(1)
   {

       if(PORTCbits.RC2==1) 
       {

          PORTCbits.RC1=1; 
       }
       else if(PORTCbits.RC2==0)
       {

          PORTCbits.RC1=0; 
       }
   }
}

Link to circuit giving 3.3v output

\$\endgroup\$
  • \$\begingroup\$ what is the actual measured voltage at PINC2 when high and low? Are there any other connections to PINC2 other than opto-coupler output? Any other connections to PINC1 (pullup/pull down/ other circuitry)? Does the circuit work without opto? (Driving PINC2 from 3 .3 V supply directly?) Lastly, can you pls independently check that whether you are indeed driving the PINC1 high and low..Try toggling it directly in the code? \$\endgroup\$ – Umar Aug 11 '15 at 12:51
  • \$\begingroup\$ 1) actual measured voltage at PINC2 at low=0.75 & how can I measure it at high becuase I am applying 3.3v from couplers. 2)no connections at PINC2. 3)no connections at PINC1,but dont know about pull down/high as it is IO expansion board.When there is nothing it is 3.276v so maybe it is pull up. 4)yes it work without optocoupler, I made a program of switch and led and it works. 5) yes it is working \$\endgroup\$ – Aircraft Aug 11 '15 at 13:03
  • \$\begingroup\$ pls isolate the PinC2 and measure the high and low output voltage levels using a DMM. Also, pls post the high and low values when you connect PinC2 to opto. \$\endgroup\$ – Umar Aug 11 '15 at 15:01
1
\$\begingroup\$

Additionally to your TRISC configuration you might have to clear the ANSC register. This sets the port to didital mode and disables the analog functions of the pin. You did not mention the exact PIC model so I can't check on the exact functionality of RC1. I came across this once when I configured a pin as UART input but the input did never read the digital Rx because it was configured as an analog pin. I would furthermore check all other functions of RC2, and configure all those functions as disabled (e.g. ADC).

\$\endgroup\$

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.