View previous topic :: View next topic |
Author |
Message |
varun
Joined: 03 Feb 2011 Posts: 2 Location: 91
|
Beginner - CCS compiler |
Posted: Thu Feb 03, 2011 3:35 am |
|
|
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
|
|
Posted: Thu Feb 03, 2011 7:50 am |
|
|
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
|
|
Posted: Thu Feb 03, 2011 9:50 am |
|
|
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
|
|
Posted: Sat Feb 05, 2011 3:43 am |
|
|
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
|
|
Posted: Sat Feb 05, 2011 6:30 am |
|
|
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
|
|
Posted: Sat Feb 05, 2011 11:09 am |
|
|
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 |
|
|
|