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.

Cannot even run the simplest LED blink in PIC18f...please suggest

Status
Not open for further replies.

Jaffry

Member level 1
Member level 1
Joined
May 16, 2012
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,594
Dear all,

I am using PIC18f4550 while using winPIC programmer for downloading, the thing is that I want to generate the clock and although this is the simplest thing just toggle the port I cannot do that.

Also I tried to just glow the LED constantly, even then it is not glowing, instead it is lighting intermittently which is of course not proper, It seems to be so smallest of tasks but I am all messed up for two days and cannot even glow a constant LED. following is the code, please suggest. I had the deadline to complete this till tomorrow and had to present some results in our lab meeting but now I cannot.

If any one has used the winPIC downloader program, I think there is some problem with the configuration bits

Code:
#include <htc.h>

__CONFIG(1,0x0F24);
__CONFIG(2,0X0000);

void main()
{
   //Initialize PORTD
   //PD0 as Output
   TRISD=0b11111100;

   //Now loop forever blinking the LED.
   while(1)   {  LATD=0B00000011;  //PORTD0 = HIGH	   }
}

Thanks
 

The problem with WinPIC (at least when I used it) was that it ignored the configuration bits settings set in the code and expected you to set them manually in the software. Set the proper configuration bits settings manually in WinPIC and try again.
 
  • Like
Reactions: Jaffry

    Jaffry

    Points: 2
    Helpful Answer Positive Rating
so in my code I set only first and second configuration register, the other registers I did not set, should I check the data sheet for them or should I only change the top 2 registers(which when I checked were right).

Also I am using 20 Mhz clock with 22pF capacitors, but I dont know what is the relationship b/e capacitors and oscillator. Any idea what my frequency would be
 

I don't know about WinPIC. the capital B some times have the problem in bit assignment of normal Mplab software. change it and then check.. Before you do check the config properly.
Code:
while(1)   {  LATD=0[B]B[/B]00000011;  //PORTD0 = HIGH	   }  // change it small b
}
and also know that, it is not blinking.It always on .Both the PINS RD0 and RD1 goes to High. So always on.

- - - Updated - - -

so in my code I set only first and second configuration register, the other registers I did not set, should I check the data sheet for them or should I only change the top 2 registers(which when I checked were right).

Also I am using 20 Mhz clock with 22pF capacitors, but I dont know what is the relationship b/e capacitors and oscillator. Any idea what my frequency would be

So you used the external Oscillator. So you need to mention the config as external Oscillator.
 
  • Like
Reactions: Jaffry

    Jaffry

    Points: 2
    Helpful Answer Positive Rating
Thank you it works.

Now I just put the code for blinking LED code as the clock generator, and then check the signal at the Oscillosope, but the signal worse, It is some worst distorted shape of the sine wave sort of something. It is good to glow the LED but not suitable for the Clock, what do you guys suggest for the clock.

I have read some where using PWM something can be done, but I think Blinking LED code should work as the clock generator since it is just ON/OFF..

by the way, if I am not mistaken, the output of PIC is TTL based.

Bests,
jaffry

- - - Updated - - -

any idea please ...!
 

Ah very sorry, the issue is already resolved, I actually was checking in Oscilloscope with the AC coupling.
Thank you very much for assistance

Bests,
jaffry
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top