• 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.

Get starting with pic18f452

Status
Not open for further replies.

unicorn

New Member
Hello everybody
I have a problem with pic18f452 that it I do the follows to test the pic first:
first I use very simple program that outputs high all the time on the port B for example.
but when I measure the voltage on the output port it gives 0v :(
I have run this program with pic16f84 and more other programs on this pic with no problems.
but it is my first time to use 18f452
I think there is problem in my initialization code of the pic
I make the powerup timer = disable
watchdog = disable
brownout = disable
If it is possible to send me link of c samples codes of pic18f452
 

unicorn

New Member
#include<18f452.h>
#fuses HS,NOWDT,NOPROTECT,NOPUT ,NOBROWNOUT

void main()
{
while(1)
output_B(255)
}
}
 
Last edited:

unicorn

New Member
you r right it was my fault I didn't copy the original code from the compiler
I wrote it online but the program is ok and build succeeded
 

be80be

Well-Known Member
That not so 16f84 has two tris register
16F84 doesn't have a TRIS .
TRISA AND TRISB I think you mean it don't take much to set up a 16f84a. The 18fxxx you have to set a lot up .
Code:
void main (void)
{
  /* Make all bits on the Port B (LEDs) output bits.
   * If bit is cleared, then the bit is an output bit.
   */
  TRISB = 0;

  while (1)
    {
      /* Reset the LEDs */
      PORTB = 0;

      /* Delay so human eye can see change */
      delay ();

      /* Light the LEDs */
      PORTB = 0x5A;

      /* Delay so human eye can see change */
      delay ();
    }
}
 
Last edited:

be80be

Well-Known Member
This is for the 16f84a
PortA On any device reset, these pins are configured as inputs
PortB unchanged
 

unicorn

New Member
I get tierd with this pic i don't know where is the wrong help me
this is the circuit
MyPicx.com - circuit

and this is the program


#include<18f452.h>
#fuses HS,NOWDT,NOPROTECT,NOPUT ,NOBROWNOUT
#use delay(clock=4000000)
void main()
{
set_tris_b(0);
while(1)
{
output_b(255);
delay_ms(1500);
output_b(0);
delay_ms(1500);
}
}


I use ccs compiler
the problem is there is no output and when I measure the input voltage in the circuit I get 0V
I connect the MCLR(Reset)pin to the VCC
Please help me
 

be80be

Well-Known Member
Try this and see
Code:
#include<18f452.h>
#fuses XT,NOWDT,NOPROTECT,NOPUT ,NOBROWNOUT
#use delay(clock=400000) 
void main()
{
set_tris_b(0);
while(1)
{
output_b(255);
delay_ms(1500);
output_b(0);
delay_ms(1500);
}
}
You are using a 4mhz Crystal/Resonator you set it for 40mhz
and HS is for 8 and 16 mhz
 

unicorn

New Member
I have tried this code and change the HS to XT,, and get the same previous results
the question is why when I put the voltage source in my circuit and measure it in the circuit it becomes 0V and when I release it from the circuit it returns again to 5V what does this mean??
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top