CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18F452 LED problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
help
Guest







PIC18F452 LED problem
PostPosted: Fri Jun 01, 2007 11:00 pm     Reply with quote

Helllo,
I am a beginner for the PIC18F452 chip. I tried to test a simple circuit. I would like to light on LED on A1, A2 and A3. It doesn't work. When I pull out the 9V adaptor, LED (A1, A2 and A3) suddenly on then off. Could any expert help me? Thanks a lot!!
Hardware:
- Connect 1k ohms with LED on A1, A2 and A3 pin.
- Connect potentiometer with 5V pull-up on A0 and A5.
- Connect voltage regulator to supply Vdd 5V
- Connect oscillator on OSC1 and OSC2
- MCLR for reset

Software (with CCS code)
#include <18f452.h>
#include <stdlib.h>
#include <CTYPE.h>
#include <STDDEF.h>
#include <STDLIB.h>
#include <STRING.h>
#include <STDIO.h>
#include <LIMITS.h>
#include <SETJMP.h>
#use fast_io(A)

void main ()
{

output_high(PIN_A1);
output_low(PIN_A2);
output_high(PIN_A3);

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 01, 2007 11:06 pm     Reply with quote

See this post for an example of a first program for the 18F452.
It blinks an LED on pin B0.
http://www.ccsinfo.com/forum/viewtopic.php?t=23106&start=4
help
Guest







PIC18F452 LED problem
PostPosted: Fri Jun 01, 2007 11:13 pm     Reply with quote

Sorry, I repost the software...

#include <18f452.h>
#include <stdlib.h>
#include <CTYPE.h>
#include <STDDEF.h>
#include <STDLIB.h>
#include <STRING.h>
#include <STDIO.h>
#include <LIMITS.h>
#include <SETJMP.h>
#use fast_io(A)


void main ()
{
set_tris_a(0xF1);
output_high(PIN_A1);
output_low(PIN_A2);
output_high(PIN_A3);

}
help
Guest







PIC18F452 LED problem
PostPosted: Fri Jun 01, 2007 11:30 pm     Reply with quote

PCM programmer,
I tried the code you provide and change the "B0" to A1. The problem is still there. When I pull out the 9V adaptor, the A1 LED on then off...Thanks...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 01, 2007 11:47 pm     Reply with quote

I changed the pin to A1 as shown below, and compiled with PCH vs.
4.039 and tested it on a PicDem2-Plus board. It works OK. It blinks
the LED.

If this code doesn't work, I think either your programmer doesn't work
or you have some other hardware problem on your board.
Code:

#include <18F452.h>
#fuses XT, NOWDT,NOPROTECT, PUT, BROWNOUT, NOLVP
#use delay(clock = 4000000)   
//====================================
void main()
{

while(1)
  {
   output_high(PIN_A1);   
   delay_ms(500);

   output_low(PIN_A1);
   delay_ms(500);
  }

}
help
Guest







PIC18F452 LED problem
PostPosted: Sun Jun 03, 2007 7:00 am     Reply with quote

It works! I change #fuses setting to HS and NOLVP. Thank you!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group