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

pic16f767 #fuse problem

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







pic16f767 #fuse problem
PostPosted: Wed Sep 22, 2004 11:40 am     Reply with quote

I have tested this main() code a 16f876 and it worked.

It seems that the clock is off, seems like its not using the external clock. Is something wrong with the #fuses? I am trying to use a 1mhz external clock.

Thanks

Nick




Code:
#include <16F767.h>
#fuses LP,NOWDT,NOPROTECT,EC_IO

#use delay(clock=   1000000)
#use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12



void main() {           // This function waits for either ~2ms or until a


  while(true)
  {
    output_high(PIN_B3);
    delay_us(1000);
    output_low(PIN_B3);
    delay_us(1000);
    printf("Hello\n");
  }


}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 22, 2004 12:32 pm     Reply with quote

Quote:
#fuses LP,NOWDT,NOPROTECT,EC_IO

You have two oscillator settings in your #fuses statement.

You've got LP ("Low power oscillator") which is for a 32 KHz
crystal and you've got EC_IO ("External clock with RA6
configured as an I/O pin").

You need to get rid of one of them.
Nick
Guest







PostPosted: Thu Sep 23, 2004 1:01 pm     Reply with quote

I removed the internal fuse and It still wants to use the internal 32khz clock.


Anyone have any ideas? I have the physical setup correct because I have test it with an 876 chip and it works perfect.

Nick



Code:
#include <16F767.h>
#fuses NOWDT,NOPROTECT,EC_IO

//#use delay(clock=      32000)32khz (internal
#use delay(clock=   1000000) //1mhz
#use rs232(baud=110, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12



void main() {           // This function waits for either ~2ms or until a


  while(true)
  {
    output_high(PIN_B3);
    delay_us(1000);
    output_low(PIN_B3);
    delay_us(1000);
    printf("Hello\n");
  }


}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 23, 2004 1:14 pm     Reply with quote

What's your version of the compiler ?
Nick
Guest







PostPosted: Thu Sep 23, 2004 1:20 pm     Reply with quote

pcm 3.187 purchased a licence about 20 days ago.

Nick
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 23, 2004 1:57 pm     Reply with quote

You might try adding the line shown below in bold. According to
the data sheet, the PIC is supposed to power-up in "OSC_NORMAL"
mode by default, but try it anyway.
Also, what pin on the PIC are you applying the 1 MHz clock to ?
What is generating the 1 MHz clock ?

#include <16F767.h>
#fuses NOWDT,NOPROTECT,EC_IO
#use delay(clock=1000000)
#use rs232(baud=110, xmit=PIN_C6, rcv=PIN_C7)
void main()
{
setup_oscillator(OSC_NORMAL);
while(true)
{
output_high(PIN_B3);
delay_us(1000);
output_low(PIN_B3);
delay_us(1000);
printf("Hello\n");
}


}
Nick
Guest







PostPosted: Thu Sep 23, 2004 2:12 pm     Reply with quote

I have a CR 1mhz clock. I got it from digi key, someone from this board recommended it. It has work great with the 876 chip.

I added that line and it didnt fix the problem.

I guess I should report this as a bug.


Nick
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 23, 2004 2:18 pm     Reply with quote

I don't know if it's a bug. It just means that you or I don't
completely understand the problem, as of this point.
The 16F767 has a more complicated selection of oscillator
modes than the 16F876. I don't have one to test, and I
don't know your test circuit for sure.

By the way, what is "CR" ? What does it stand for ?
What is the Digikey part number ?
Nick
Guest







PostPosted: Thu Sep 23, 2004 2:24 pm     Reply with quote

My test board is working, atleast with the 876. It will work if I change the clock to 37khz in the 767 code. So I'm pretty sure that the test board is working. Its just an LED + resistor and a max 232 hooked up and given 3v. Nothing fancy. I am trying to get this setup working first before I try it on the actually project board.

CR = Ceramic Resonators

My 1mhz clock is from Digikey pn# X926-ND. www.digikey.com pg. 626


Thanks for the help,

Nick
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 23, 2004 2:43 pm     Reply with quote

OK. Finally, we're getting somewhere.

A ceramic resonator is not an "external clock".
Furthermore, the one that you are using is not a 3-pin type,
so it's going to need external capacitors in order to work properly.
See the data sheet here:
http://www.ecsxtal.com/pdf/ztb.pdf
According to the 16F767 data sheet, you should use "XT" mode
for a 1 MHz resonator. So change your #fuses statement to be:
#fuses XT, NOWDT,NOPROTECT

When you said "external oscillator", you used a term that refers
to this type of device: http://www.ecsxtal.com/surfosc.htm
These are complete oscillators in a "can" package. (but can also
be in plastic packages).
Nick
Guest







PostPosted: Fri Sep 24, 2004 9:45 am     Reply with quote

I swapped out the 2 pin clock for a 3 pin type clock and a square metal clocks, both work with the 876, but the 767 is still using the internal clock.

I was looking at the function you posted

"setup_oscillator"

There should be a 1mhz internal clock in the chip that I can use. I would like to figure out out the function "setup_oscillator" works but its not in my help file.

Nick
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 24, 2004 12:11 pm     Reply with quote

Quote:

I would like to figure out the function "setup_oscillator" works but it's not
in my help file.

For information on that function, look in the README.TXT file in this
folder: c:\Program Files\Picc

For a list of parameters used with that function, look in the 16F767.H
file. It's in this folder: c:\Program Files\Picc\Devices
Guest








PostPosted: Fri Sep 24, 2004 12:57 pm     Reply with quote

PCM programmer wrote:
Quote:

I would like to figure out the function "setup_oscillator" works but it's not
in my help file.

For information on that function, look in the README.TXT file in this
folder: c:\Program Files\Picc

For a list of parameters used with that function, look in the 16F767.H
file. It's in this folder: c:\Program Files\Picc\Devices



Thanks, I got it


Here is the corrected code

Code:


#include <16F767.h>
#fuses NOWDT,NOPROTECT
#use delay(clock=1000000)
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7)
void main()
{
setup_oscillator(OSC_1MHZ);
while(true)
{
output_high(PIN_B3);
delay_us(1000);
output_low(PIN_B3);
delay_us(1000);
printf("Hello\n");
}


}

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