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

Beginner - CCS compiler

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



Joined: 03 Feb 2011
Posts: 2
Location: 91

View user's profile Send private message

Beginner - CCS compiler
PostPosted: Thu Feb 03, 2011 3:35 am     Reply with quote

hello. Just started working with CCS compiler. I am struggling to make a program work. I have powered up with +5v, grounded VSS and having Crystal - 4Mhz + 22pf. Nothing else. Can anyone please figureout if i am making anything wrong in the pgoram.

Code:


#include <16F73.h>
#fuses XT,NOWDT,PUT,NOBROWNOUT,PROTECT
#use delay(clock=4000000)


#byte PORTA=0x05
#byte TRISA=0x85

#bit ff=PORTA.0
#bit fs=PORTA.2
void main()
{

set_tris_a(0x00);
PORTA=0x00;

fs=1;
   while(1)
   {
      
      ff=0;
      delay_ms(1000);
      ff=1;
      delay_ms(1000);
      
   }

}
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Thu Feb 03, 2011 7:50 am     Reply with quote

You are doing things the hard way - CCS makes a lot of things much simpler, but you're probably used to a different compiler? Try this:
Code:
#include <16F73.h>
#fuses XT,NOWDT,PUT,NOBROWNOUT,PROTECT
#use delay(clock=4000000)

#define PIN_FF PIN_A0
#define PIN_FS PIN_A2

void main()
{

   output_a(0x00);

   output_high(PIN_FS);
   for (;;)
   {
       
      output_low(PIN_FF);
      delay_ms(1000);
      output_high(PIN_FF);
      delay_ms(1000);
       
   }

}
("for(;;)" is a C trick that's the same as "while (1)" but without the compiler warning)
_________________
Andrew
Ttelmah



Joined: 11 Mar 2010
Posts: 19497

View user's profile Send private message

PostPosted: Thu Feb 03, 2011 9:50 am     Reply with quote

Also one other obvious thing. Pullup resistor on MCLR, or the processor won't run.

Best Wishes
varun



Joined: 03 Feb 2011
Posts: 2
Location: 91

View user's profile Send private message

PostPosted: Sat Feb 05, 2011 3:43 am     Reply with quote

Surprised Thank you for your reply. I was missing the MCLP pull up. I will remember form now on. I also wanted to ask you this. i want to use RA0 as output, RA1 as analogue input and all others as input. Can I configure this way? and how.
temtronic



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

View user's profile Send private message

PostPosted: Sat Feb 05, 2011 6:30 am     Reply with quote

You need to find the '16F73.h' file in the DEVICES folder and open it. It will list the various peripherals and their configurations that you can use.
I usually have it opened and refer to it during a project's first few versions as you can cut and paste from it.
gpsmikey



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

View user's profile Send private message

PostPosted: Sat Feb 05, 2011 11:09 am     Reply with quote

To add to Temtronic's comment - the "devices" folder is under the PICC directory where it was installed on your machine - usually in "C:\Program Files\PICC" (in the main PICC folder, there is also a "fuses.txt" file that lists the fuse names and a bit about them).

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