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 CCS Technical Support

blink led program in pic18F8722
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hemnath



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

blink led program in pic18F8722
PostPosted: Fri Dec 12, 2014 9:00 am     Reply with quote

I have a very strange problem.

I have bought a 18F8722 development board. It has 18F8722, 20Mhz crystal, MAX232, RS232, I/O pins and 5V regulator.

Blink led code:
Code:
#include "18F8722.h"
#fuses HS, NOWDT, NOLVP
#use delay(clock=20000000)

void main()
{
   while(1)
   {
      output_high(PIN_D0);
      delay_ms(500);
      output_low(PIN_D0);
      delay_ms(500);
   }
}


LED should blink for every 500ms. But the led is ON for 10 sec and OFF for 10 sec approximately.

What could be the problem?
Please help.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Dec 12, 2014 9:13 am     Reply with quote

For some reason the crystal is not running.

This chip (in common with a lot of later ones), has a thing called 'fail safe clock monitor'. If the selected primary oscillator isn't running, it drops 'back' to a default internal oscillator. 1MHz.

Could be a faulty crystal, bad connection, etc. etc..
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Dec 12, 2014 9:19 am     Reply with quote

Another potential problem is if your program was compile in 'debug' mode and not 'release' mode.
For the PIC to run correctly you need to compile in 'release' mode.

and... be sure ICD=true is NOT used ! as it'll setup the PIC differently than you want as well....



Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Dec 12, 2014 10:03 am     Reply with quote

and (of course), could then be compiling through MPLAB, which defaults to debug mode.....
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 12, 2014 11:27 am     Reply with quote

Quote:
I have bought a 18F8722 development board.

Post a link to the website for your board. Post your compiler version.
hemnath



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

PostPosted: Fri Dec 12, 2014 9:12 pm     Reply with quote

Thanks for the help. I modified the program for internal oscillator. It blinks for every 500ms.

I'll change the crystal and post the results.
hemnath



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

PostPosted: Sat Dec 13, 2014 7:25 am     Reply with quote

Even when I changed the crystal., Problem remains the same.

I bought the development board from local market.
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Dec 13, 2014 7:36 am     Reply with quote

You still didn't post the compiler version...
_________________
Google and Forum Search are some of your best tools!!!!
hemnath



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

PostPosted: Sun Dec 14, 2014 12:18 am     Reply with quote

Compiler version CCS 4.114
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sun Dec 14, 2014 1:40 am     Reply with quote

A relatively old compiler, but the 8722, had been supported for a long time. There was something wrong with the include file back in the late 4.0xx's, but you are after this. Anyway the compiler version wouldn't affect this unless it was setting the fuses incorrectly. A quick compile of the code, shows one thing wrong. It is defaulting to XINST. You need to NOXINST fuse. This though should not cause problems on the simple code posted (only causes problems with things like table accesses etc..). However correct this for the future.

Can you check the capacitors used to load the crystal?. Could be something silly like these being 22nF, instead of 22pF for example....

Do you know anything 'about' the crystals you have?. What cut they are, what load capacitance they want, etc..

Triple check around the connections with a magnifying glass. A simple whisker, if the board has not been electrical tested, could easily be the problem.

The 8722, is a chip that I have had problems with in the past, getting the oscillator to always start. Quite a few crystals do need a series resistor on this chip (though lacking this tends to result in the frequency being 'out of spec', rather than stopping the oscillator working). Microchip recommend 330R. I've also though found that the internal resistor across the crystal terminals may not be enough to ensure all crystals start reliably, especially if the power rise time is slow. Something like 1.5MR between the oscillator terminals solves this.
hemnath



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

PostPosted: Sun Dec 14, 2014 4:27 am     Reply with quote

I have changed a new crystal and capacitors. Still no blinking.
Also double checked the connections from crystal to micro-controller pins.
Also, added a resistor with a value of 1Mohm(i dont have 1.5Mohm right now) across crystal. Still no blinking on led.

my code:
Code:
#include "18F8722.h"
#fuses HS, NOWDT, NOLVP, NOXINST,  NOFCMEN, NOIESO, NOPUT
#use delay(clock=20000000)

void main()
{
   while(1)
   {
      output_high(PIN_D0);
      delay_ms(500);
      output_low(PIN_D0);
      delay_ms(500);
   }
}


Please help. whether my fuses are right? Do i have to add anyother fuses?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 14, 2014 4:15 pm     Reply with quote

Quote:
I have changed a new crystal and capacitors. Still no blinking.

I bought the development board from local market.

Post an in-focus, HD-quality photo of your board.

How to post an image on the CCS forum:
Post it on a free image hosting website. Examples:
http://postimage.org
http://tinypic.com
https://imageshack.com

Then post a link to it here.
hemnath



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

PostPosted: Mon Dec 15, 2014 8:07 am     Reply with quote

Below are the links.. Please help me to solve the problem. http://www.nskelectronics.com/pic_18f8723_80_io__target_board_.html


http://hacktronics.co.in/home/36-pic-18f8722-18f8723-target-io-board.html
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 15, 2014 11:12 am     Reply with quote

The board has 9 header connectors for i/o ports. The crystal pins, A6
and A7, are connected to one of the headers.
Have you added any wires or connections to pins RA6 or RA7 on the
header connector ? This could certainly affect the crystal circuit.

I don't like the fact that they put long traces between the crystal circuit
and the header pins. The crystal circuit should have been left alone,
with only the required connections to the capacitors and the PIC.
It's possible that the long traces to the header are affecting the circuit.

I suggest that you use an Ohmmeter, and carefully check for continuity
of the traces between the PIC pins and the crystal circuit, and all traces
within the crystal circuit. Also check for shorts between traces.
Look at PIC pins A6 and A7 with a magnifier and check for bad solder
joints. Using an X-Acto knife with a magnifier, carefully nudge pins A6
and A7 to check if they are really soldered to the PCB, or if they are loose.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Dec 15, 2014 1:03 pm     Reply with quote

As PCM suggests, be sure an use an ohmmeter - even if there is nothing visible under a magnifying glass, there still may be an issue. I had one a few years ago where we absolutely could not find the problem until we checked continuity - turns out an internal void between vias in the board had allowed the "thru-hole" plating they use for the vias to bridge between two pins on the board and that was NOT visible - even when we knew where it was.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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