Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC12F1840 , cant get RA4 To output

Status
Not open for further replies.

burrow

Full Member level 2
Joined
Dec 15, 2014
Messages
147
Helped
3
Reputation
6
Reaction score
3
Trophy points
18
Activity points
1,148
Hai, iam but familier with PIC programming, But this time one issue is giving me a big headache.

I am using PIC12F1840, i am not able to get output on RA4.
It simply gives zero volt, When i attach a 10k pullup It constantly gives me 5v.

i have set TRISPIN, I have disabled adcon etc..
The code works in simulation
Attaching my code

Code:
void main() {

  TRISA.B2=1;
  TRISA.B5=1;
   TRISA.B4=0;
   TRISA.TRISA4=0;
    TRISA.TRISA0=0;
    TRISA.TRISA2=1;


WPUA.WPUA4=1;

INTCON.GIE=0;


ANSELA.ANSA0=0;
ANSELA.ANSA1=0;
ANSELA.ANSA2=0;
  ANSELA.ANSA4=0;
    TRISA.TRISA0=0;







APFCON.TXCKSEL=0;
APFCON.SDOSEL=0;

ADCON0.ADON=0;
DACCON0.DACEN   =0;
SRCON0.SRLEN=0;
CM1CON0.C1ON=0;
MDCON.MDEN=0;

    INTCON.INTE=0;
    INTCON.INTF=0;

      TRISA.TRISA4=0;


      while(1)
{




          LATA.LATA4=1;
          delay_ms(500);
            LATA.LATA4=0;
              delay_ms(500);
        }


}

MCLR is connected to Vcc via a 10k Resistor, tried connecting it directly too.
Tried RA4 with and without Pull Up, Datasheet says its a CMOS output.
 

I'm guessing this is related to your other thread.

Which compiler are you using?
Please explain the difference between 'TRISA.B2' and 'TRISA.TRISA2' if there is any.
WPUA.WPUA4=1; suggests you want the internal pull-up on RA4 to be active so the pin should be high at all times unless you are driving it low.

I am assuming you have the config words set to use the internal oscilator modes and you have not configured RA4 as the CLKOUT pin and also you have not configured the Watchdog timer to let it reset so quickly it can't execute your code.

The MCLR can be tied directly high or through a resistor, it shouldn't change the way it works. Obviously use a resistor if something else has to pull it low.

Brian.
 

hello,



LATA.LATA4=1; ?

i have an application wich use RA4 as output connected to a led
Code:
sbit Led_Blanche at LATA4_bit ;     // RA4
sbit Led_Blanche_direction at TRISA4_bit

the main difference i see is :
i used LATA4_bit=1;
Code:
 ANSELA=0;
Led_Blanche_direction=0;
 Led_Blanche=1;     //   led pulled up trough R=4,7K  so  need 0 to bright ON the led
.....

 Led_Blanche= !Led_Blanche; // blink RA4
 

To set RA4 as an output pin you need to turn off the analogue inputs (which you have done), and also set the configuration bits 2-0 set to 100 and bit 11 set to a one.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top