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

What am i doing wrong?

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



Joined: 08 Sep 2011
Posts: 5

View user's profile Send private message

What am i doing wrong?
PostPosted: Thu Sep 08, 2011 11:52 am     Reply with quote

I can't get this test code to work, the chip is just dead. I know the chip works, as i made it work in CC5x with the same param/chip. I'v been designing PCB's for a while, so im probably just missing somethig obvious Smile
(With CLKOUT and my osc to that pin theres just noise)

Thanks
//Nimo

Code:

#include <16f676.H>


#fuses INTRC_IO
#fuses NOWDT,NOPROTECT
#fuses NOBROWNOUT,NOMCLR,PUT

#use delay(internal=4000000)

#byte TRIS_C    = 0x87
#byte TRIS_A    = 0x85

#byte PORT_C    = 0x07
#byte PORT_A    = 0x05

#byte OSCCAL    = 0x90
#byte ANSEL    = 0x91
#byte ADCON0    = 0x1F
#byte ADCON1    = 0x9F
#byte CMCON    = 0x19

#bit LED1       = PORT_C.0
#bit RELAY       = PORT_A.0

void main(void)
{
ANSEL = 0;
CMCON = 8;
OSCCAL = 256;
TRIS_C=0b11000000;
TRIS_A=0b11111100;


while(1){
   delay_ms(1000);
   LED1=1;
   RELAY=1;
   delay_ms(1000);
   LED1=0;
   RELAY=0;
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 08, 2011 12:20 pm     Reply with quote

Quote:
OSCCAL = 256;

You're writing a 9-bit number to an 8-bit register.

Basically you're writing Hi-Tech code. You don't have to do this with CCS.
With CCS you can do rapid program development by using their built-in
functions. The compiler will set the TRIS for you, and it will setup a lot of
everything else too (if you let it).

Here is an example of blinking an LED with the 16F676 by using CCS functions:
http://www.ccsinfo.com/forum/viewtopic.php?t=32914&start=1
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Sep 08, 2011 1:04 pm     Reply with quote

as soon as i realized the true power of CCS - it really became impossible
to consider any other way to program a pic.
Oh -yes - re: blink a led - 'hello world' program?
can you do it with fewer lines of code than THIS ?

Code:

#include <16F676.H>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock = 4000000)

void main(){
while(1)
    {    output_toggle(PIN_C4);    delay_ms(500);  }

}


try THAT with Hi tech ;-))
Nimo75



Joined: 08 Sep 2011
Posts: 5

View user's profile Send private message

PostPosted: Thu Sep 08, 2011 1:05 pm     Reply with quote

yea... i saw that Embarassed But thats not the error, think it just reads it as 0's, minimum freq. I tryed the code you linked to, and that won't work either. Question
Nimo75



Joined: 08 Sep 2011
Posts: 5

View user's profile Send private message

PostPosted: Thu Sep 08, 2011 1:22 pm     Reply with quote

asmboy wrote:
as soon as i realized the true power of CCS - it really became impossible
to consider any other way to program a pic.
Oh -yes - re: blink a led - 'hello world' program?
can you do it with fewer lines of code than THIS ?

Code:

#include <16F676.H>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock = 4000000)

void main(){
while(1)
    {    output_toggle(PIN_C4);    delay_ms(500);  }

}


try THAT with Hi tech ;-))


With the nicname asmboy, that says something Smile
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Sep 08, 2011 1:42 pm     Reply with quote

disclosure - i started in ASM for first few PIC projects
then tried hitech and source boost
but only use CCS now
Nimo75



Joined: 08 Sep 2011
Posts: 5

View user's profile Send private message

PostPosted: Thu Sep 08, 2011 2:36 pm     Reply with quote

asmboy wrote:
disclosure - i started in ASM for first few PIC projects
then tried hitech and source boost
but only use CCS now


No need to defend my friend Smile I love to be proved wrong... or else i would stop thinking.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 08, 2011 4:04 pm     Reply with quote

Quote:

But thats not the error, think it just reads it as 0's, minimum freq. I tryed
the code you linked to, and that won't work either.

1. Can you make the simply LED turn on and stay on with CCS ?
That's the first thing to get working.

2. What's the Vdd voltage on your PIC ? Is it +5.0 volts ?

3. What's your CCS compiler version ? It's a 4-digit number (only) given
at the top of the .LST file, which will be in your project directory after a
successful compilation. Examples of CCS version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
Nimo75



Joined: 08 Sep 2011
Posts: 5

View user's profile Send private message

PostPosted: Thu Sep 08, 2011 4:41 pm     Reply with quote

PCM programmer wrote:
Quote:

But thats not the error, think it just reads it as 0's, minimum freq. I tryed
the code you linked to, and that won't work either.

1. Can you make the simply LED turn on and stay on with CCS ?
That's the first thing to get working.

2. What's the Vdd voltage on your PIC ? Is it +5.0 volts ?

3. What's your CCS compiler version ? It's a 4-digit number (only) given
at the top of the .LST file, which will be in your project directory after a
successful compilation. Examples of CCS version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo


Just to be square, i have built the HW and written the code for a MP3 player in CCS, so i know how it works, but this little chip just won't work....
It might be a HW fault or some little bug....

BR
//Nimo


I'm thankfull for all the support....
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Sep 08, 2011 6:59 pm     Reply with quote

Nimo75 wrote:
Just to be square, i have built the HW and written the code for a MP3 player in CCS, so i know how it works, but this little chip just won't work....
So you are smart, just like us. Cool
We can't read you mind and in order to help you we need more info. Please answer question 2 and 3.
You can speed up things by providing more info, like the tests you have performed and a description or schematic of the circuit.
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