View previous topic :: View next topic |
Author |
Message |
Nimo75
Joined: 08 Sep 2011 Posts: 5
|
What am i doing wrong? |
Posted: Thu Sep 08, 2011 11:52 am |
|
|
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
(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
|
|
Posted: Thu Sep 08, 2011 12:20 pm |
|
|
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
|
|
Posted: Thu Sep 08, 2011 1:04 pm |
|
|
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
|
|
Posted: Thu Sep 08, 2011 1:05 pm |
|
|
yea... i saw that 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. |
|
|
Nimo75
Joined: 08 Sep 2011 Posts: 5
|
|
Posted: Thu Sep 08, 2011 1:22 pm |
|
|
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 |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Sep 08, 2011 1:42 pm |
|
|
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
|
|
Posted: Thu Sep 08, 2011 2:36 pm |
|
|
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 I love to be proved wrong... or else i would stop thinking. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 08, 2011 4:04 pm |
|
|
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
|
|
Posted: Thu Sep 08, 2011 4:41 pm |
|
|
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
|
|
Posted: Thu Sep 08, 2011 6:59 pm |
|
|
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.
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. |
|
|
|