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

Just got my PIC C program in the mail! A few basic questions

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



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

Just got my PIC C program in the mail! A few basic questions
PostPosted: Tue Aug 11, 2009 10:00 pm     Reply with quote

So my boss just spent $500 on the C software compiler and the ICD-U64 programming unit, and he expects me to know how to use it. I'm a PICBASIC programmer, so getting used to C will take me some time, though with some past video game programming experience I'm picking it up rather quickly.

My problem is getting to know the software. I've read through the manual a few times, word for word. I've written the following program, and I want to program it to my PIC16F684 microcontroller chip, but the option to program the ICD chip is greyed out, as is the option for MACHX. I've installed everything correctly, as stated by the included instructions card that came with the software, including the drivers for my ICD unit. Any ideas as to why the program isn't letting me use the 'Program Chip' function?

Code:

#include <16f684.h>
#device ICD=TRUE
#use delay (clock=20000000)
float x;
float y;
float z;
int input;
void main()
{
loop:
   output_high (PIN_A1);
   delay_ms( 100 );
   output_low (PIN_A0);
   delay_ms( 100 );
}


I opened the program, started a new source file, wrote the above code into the source file, compiled it with no errors, and then tried to 'Program Chip->ICD'. Am I missing something?

Thanks!
mutthunaveen



Joined: 08 Apr 2009
Posts: 100
Location: Chennai, India

View user's profile Send private message

i think this will make
PostPosted: Wed Aug 12, 2009 4:37 am     Reply with quote

crazy programing
When I was new to PIC C I faced the same problem.
Code:
#include <16f684.h>
#device ICD=TRUE
#fuses NOWDT, NOPROTECT
#use delay (clock=20000000)
float x; // not required
float y; // not required
float z; // not required
int input; // not required
void main()
{
loop: // mentioned loop but forgot to add "goto"
   output_high (PIN_A1); // declared here as A1
   delay_ms( 100 );
   output_low (PIN_A0); // declared here as A0 " then how A1 go off"
   delay_ms( 100 );
   goto loop;
}


You can try this too:
Code:

#include <16f684.h>
#device ICD=TRUE
#fuses NOWDT, NOPROTECT
#use delay (clock=20000000)

void main()
{
while(1)
  {
   output_high (PIN_A1);
   delay_ms( 100 );
   output_low (PIN_A1);
   delay_ms( 100 );
  }
}


If you want to read an input then:
Code:

#include <16f684.h>
#device ICD=TRUE
#fuses NOWDT, NOPROTECT
#use delay (clock=20000000)
#define input    PIN_A3
int input; // not required


void main()
{
while(TRUE){
 
   if(input==1){
   output_high (PIN_A1);
   delay_ms( 100 );
   output_low (PIN_A1);
   delay_ms( 100 ); }

}
}

Now it will be OK.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 12, 2009 10:46 am     Reply with quote

These sample programs that you posted will not work.
Quote:
#include <16f684.h>
#device ICD=TRUE
#fuses NOWDT, NOPROTECT
#use delay (clock=20000000)

void main()
{
while(1)
{
output_high (PIN_A1);
delay_ms( 100 );
output_low (PIN_A1);
delay_ms( 100 );
}
}


You did not specify an oscillator fuse. A 20 MHz crystal oscillator requires
the HS fuse. But if you don't specify a fuse, the compiler defaults to
using the RC fuse. That fuse won't work with a 20 MHz crystal.
Here are the fuses created by your program.
Quote:
Configuration Fuses:
Word 1: 3CF7 RC NOPROTECT NOBROWNOUT MCLR NOCPD NOWDT NOPUT IESO FCMEN

It's good to answer questions, but you should make sure the answer is
accurate. Maybe wait until you have more experience with CCS.

--------------------

For a simple newbie program for the 16F684, it's easier to use the internal
oscillator. Then blink an LED (with 470 ohm series resistor) on pin C0.
Example:
Code:

#include <16F684.H>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock=4000000)
   
//===========================
void main()
{

while(1)
  {
   output_high(PIN_C0);
   delay_ms(500);
   output_low(PIN_C0);
   delay_ms(500);
  } 

}

The BROWNOUT fuse is used in this program. This assumes your board
is running at +5 volts. If it's running at a lower voltage, then change the
fuse to NOBROWNOUT.
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Thu Aug 13, 2009 6:09 pm     Reply with quote

Thanks for the replies! Now that I have a working test code, I need to still figure out why my program isn't allowing me to click "Program Chip".

Does "while(1)" replace "loop"?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Aug 13, 2009 6:41 pm     Reply with quote

Read some online C tutorials that explain while() loops:
http://devjargon.com/tutorials/loops-in-c/
http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/#loops
Jim Hearne



Joined: 22 Dec 2003
Posts: 109
Location: West Sussex, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Aug 14, 2009 6:40 am     Reply with quote

Was your programmer supplied with the newer ccsload software ?
Did you install it after the compiler ?

Make sure the links in options>tools are correct, they may still point to the older icd software.

Can you run the programmer software directly from the windows start menu ?

Jim
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