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

hex file don't work
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
riz179



Joined: 06 Apr 2012
Posts: 21

View user's profile Send private message

hex file don't work
PostPosted: Tue Apr 24, 2012 9:09 am     Reply with quote

hey! Please help.
I have written a program that work well with the proteus but when i burn it on the controller there is no response in the hardware, even a single character is not displayed on LCD. Showing the starting lines of code, waiting for quick advice.
ver 4.057
Code:

#ifdef(__PCH__)
#include <pic18f452>
#DEVICE ADC=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#endif

#define use_portb_kbd TRUE
#include <kbd.c>
#include <stdio.h>
#include <stdlib.h>
#include <lcd.c>
#include <math.h>

void keypad(void);         ///function for keypad
void adcread(void);        ///...........  for reading adc
void lcdmenu(void);        ///................User interface
unsigned char adcchk=1,MAXINPUTLEN=10;  ///adcchk=> adc condition
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 9:35 am     Reply with quote

Forget Proteus. It's so full of bugs, you'll learn nothing from it.

Use the CCS samples to first establish that each individual piece of hardware is working.

Mike
temtronic



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

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 10:45 am     Reply with quote

Mike's right...GET RID of Proteus !!! reformat your harddirve and never,ever install it again !!!

also....

get rid of the if..compilr type ...code...,use the one compiler and 'hardcode' the requirements.

if..then..statements will 'get you' sooner than later...

get rid of the 'adc chk' code (last line hints at that)..
not required,just select channel, delay a bit, read,save result, move on....

once you get the CCS examples running, show us your program and we can help..

but first...
GET RID of PROTEUS !!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 11:01 am     Reply with quote

He is testing it on hardware. Here is his quote:
Quote:

but when i burn it on the controller there is no response in the hardware,


Start with a simple LED blinking program. Make sure you have all the
correct hardware connections for the crystal (and it's 22 pf capacitors),
and the 10K MCLR pull-up resistor, and +5v connected to Vcc pins and
Ground connected to Vss pins. And, don't forget the 470 ohm series
resistor on the LED.
Code:

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

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

   output_low(PIN_B0);
   delay_ms(500);
  }

ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 11:16 am     Reply with quote

Hi,

I don't know why everyone wants to start testing their hardware with the completed version of their program?? There are so many things about initial hardware debugging that are made so much easier with a SIMPLE program.

Why not try a simple program that blinks an LED? If this works, it will prove that your programmer has successfully programmed the PIC, and that your PIC is actually executing code! There are numerous LED blinking routines on the forum if you don't know how to do this.

Common problems that may explain why your hardware isn't running include:

1. Faulty power supply - have you measured Vcc on your board?
2. Missing MCLR pull-up resistor. Do you have a resistor that pulls MCLR to Vcc? What is the value?
3. Incorrect crystal or resonator. Can you put a scope on the OSC pins of the PIC to verify if your PIC is running? If equipped, will your PIC run with the internal oscillator?
4. Improper "load" capacitors on the crystal. Are they present, and what is their value?

In short, reduce your problem to the simplest possible form, and check the items above. Once you get it running, add all the other code.

John

PS Argh!! Sorry, PCM programmer, your reply wasn't there before I started typing!
riz179



Joined: 06 Apr 2012
Posts: 21

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 11:55 am     Reply with quote

Thanks to all of you guys, I'm going to check my hardware for issues you have mentioned at night with simple pieces of codes, I hope.
temtronic



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

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 12:39 pm     Reply with quote

If your hardware is exactly the way Proteus allows it to be drawn it can never work...

..it's the 'little' details...

like...

1) Proteus doesn't warn about NOT connecting Vss and Vdd..let alone correct voltage!!

2) Proteus doesn't care about MCLR

3) or wiring up the correct crystal

4) or grounding the xtal caps

5) or ........

There are a lot of BASIC requirements that the 'simulator' never cares about or warns you about any or all will not allow your project to work!

That's why it is so important to get the 'Hello World' and '1Hz LED' programs up and running.
riz179



Joined: 06 Apr 2012
Posts: 21

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 2:25 pm     Reply with quote

Programmer matters ? As I'm using EasyPic4 of MikroElectronika, as you told me to simply toggle the bits of controller for debugging but I still get 0v at 'D0'. I have 2 pieces of uC but both of them don't work for me, sorry for stupid questions but I'm new to this thing so I really need help.
temtronic



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

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 2:38 pm     Reply with quote

PCM's program toggles B0 not D0.

that could be your problem.....

You should show us your version of PCM's program.
riz179



Joined: 06 Apr 2012
Posts: 21

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 2:54 pm     Reply with quote

i tried both "B0' and "D0',
same code pcm programmer posted
if i connect MCLR directly with 5V without using 10k resistor,,what wil happen
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 3:06 pm     Reply with quote

Is this the board that you have ?
http://www.mikroe.com/pdf/easypic4/easypic4_manual.pdf

If so, to activate the LEDs on PortB, the schematic on page 17 shows
that switch 2 of SW2 must be set to "On".


Also what crystal do you actually have on the board ? On page 14
of the manual, it shows an 8.000 MHz crystal, not 20 MHz. If you
really have 8 MHz, then the #use delay() statement must be changed
to be for 8 MHz.
riz179



Joined: 06 Apr 2012
Posts: 21

View user's profile Send private message

PostPosted: Tue Apr 24, 2012 11:32 pm     Reply with quote

I'm using this board only for burning the code, and then checking the code on my own simple circuit,
MCLR==directly connected to 5V
VDD pins==5V
VSS pins=Ground
One crystal connected to 13&14 number pins with other pins connected to 22pf capacitors and then G.
I don't understand where is the problem. I don't get any change on the pin d0 or b0.
on the trainer board the led gets ON but don't toggle,i have tried various builtin functions to toggle bits of ports but only first command runs
e.g 0x55 and then 0xaa only 0x55 executes and then remains constant
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Apr 25, 2012 1:58 am     Reply with quote

Do you mean that you're:-

(1) Programming the PIC on the EasyPic4 board.
(2) Removing PIC from the EasyPic4.
(3) Then plugging PIC into your own PCB?

Are you also saying that your PCB, and the EasyPic4, behave in EXACTLY the same way?

Mike

PS. Do you have access to DVM and oscilloscope?
riz179



Joined: 06 Apr 2012
Posts: 21

View user's profile Send private message

PostPosted: Wed Apr 25, 2012 3:27 am     Reply with quote

ya i can arange,,no they are not behaving in the same way,easypic just shows the first pattern (0x55) and then don't toggle at value (0xAA)while my crkt shows nothing
Ttelmah



Joined: 11 Mar 2010
Posts: 19541

View user's profile Send private message

PostPosted: Wed Apr 25, 2012 3:53 am     Reply with quote

Step back.

Load just PCM programmer's code.
Only change the clock in this to 8MHz, since this is what the Easypic4 has.
Set SW2 as he says.

Does pin B0 toggle?.

If it does at this point you now have a working processor, and can step forward _one step at a time_.

Now a couple of comments:
First, are you using CCS "on it's own", or working through MPLAB?. If the latter, then you must change the setting, to tell it to compile for 'release', or by default it'll be setting the code up to run in 'debug' mode, and it won't run properly on a chip...
Second, general thing. _Simplify_. You have for example, a completely unnecessary #ifdef in your posted code. You should only have statements like this if you are writing code for multiple processors. This is 'why' they are present in some of the CCS examples/drivers, but they assume that you understand that these are not needed when writing code for one processor. Look at PCM programmer's code, for how simple a test can be. Then move forward one step at a time. You speak about the code only outputting the first value, but what you have posted does not output any value, so we cannot comment on what might be wrong. However it sounds as if you are trying to run, before walking.
Test things one step at a time. Start with the pin toggle.
Once this is working, test it on your stand alone chip.
Once this is working step to the next thing, possibly just displaying something.
The key to debugging is to test one item at a time.

Now on the comments about Proteus, I agree, and disagree.

As a PCB design package, it is good.

It has an analog simulator, that is very competent, allowing some things to be better modeled than in things like Pspice.

_But_ it's simulation of the PIC processors in general, is poor. Unfortunately, it misses a lot of things that will stop the processor working (won't stop if the clock doesn't match the fuses, doesn't care about good decoupling by the PIC, and doesn't accurately simulate many of the peripherals, especially on the more complex PIC's, etc. ect..).
Realistically it is a nightmare. I have designs that will simulate perfectly in this, yet can never work, and also ones that won't work in Proteus, but function completely correctly.
Though I wouldn't throw away the whole package, I'd keep it for schematic drafting, and PCB design only. Take the PIC simulation, and treat it like a 'square wheel'. Something that might look pretty hung on the wall, but is useless on a car....

Best Wishes
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