Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Initial PIC uC pin Voltage

Status
Not open for further replies.

Kminant

New Member
Hi to all,

I'm new to PIC Micro Controllers. I have been working with PIC16F877A and decided to switch to PIC18F1230 since it has more PWM channels. From the experience while working on PIC16F877A I can tell that pins must have 0V while not being set to be high on PORTx or LATx for newer PICs, am I correct? I noticed that this is not the case with PIC181230. I ran a test setting some pins as input and some as output in PORTB, also setting PORTB=0x00. When reading the voltage on the pins it ranged from 1.2V to 2.0V.

Is this normal?
Is there any register i need to configure to fix or avoid this problem?

Currently I'm working on a push button to turn on an LED. the LED must turn on when the digital signal is high. Since the pins are not working properly or are not being set properly the LED is on as soon as Vdd is 5V. Now the LED can be turned off by shorting the pin containing the button to ground.

Here is the code, it seems really straight forward but is not working. The code is done in HITECH C.

Code:
#include <htc.h>
#include <18f1230.h>
#include <delay.h>

#define XTAL_FREQ 4MHZ   //crystal FREQ

//***************************************Configuration Fuses
__CONFIG(1, HS);
__CONFIG(2, WDTDIS);
__CONFIG(3, MCLRDIS);
__CONFIG(5, UNPROTECT);

//******************************************************Main
void main(){

unsigned short old_u;

ADCON1 = 0b00001111;
CMCON = 0b00000111;
TRISB = 0b00010000;
PORTB = 0x00;

 while(1){
 
  if(RB4){
  RB1 = 1;
  old_u = 1;
  }

  if(old_u && (!RB4)){
  RB1 = 0;
  old_u = 0;
  } 
 }  
}

Thanks in advanced for the help!
 
If you have 5V on Vdd, and GND configured correctly, perhaps you have a dud PIC?

Have you tried a simple LED flash program to ensure the OSC is connected correctly?
 
You don't state if the reading is on a pin that is input or output.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top