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

16F767 test

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



Joined: 11 Sep 2006
Posts: 27

View user's profile Send private message

16F767 test
PostPosted: Tue Oct 17, 2006 8:01 am     Reply with quote

Code:
#include <16F767.h>
#use delay (clock=20000000)
#fuses HS,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,MCLR,NODEBUG,EC_IO
#byte portb=6

void main()

{

  set_tris_b(1);
  while(1){
 
Portb=0;
delay_ms(1000);
Portb=255;
delay_ms(1000);
  }


   }

Hi all, I'm trying a simple program on the PIC16F767, but it doesn't seem working.
THe compiler I'm using is CCS PCM C Compiler, Version 3.181 )from the LST file)

the hex code is below...
:1000000000308A00172800002230840000080319FD
:1000100016280630F800F701F70B0C28F80B0B2810
:100020007B30F700F70B1228800B0928003484017D
:100030001F3083050F3083169F00073083129F0007
:10004000003083168600831286010430A100FA3046
:10005000A2000420A10B2728FF3086000430A10055
:10006000FA30A2000420A10B302883162328630055
:02400E00AB3FC6
:00000001FF
;PIC16F767

Is there any problem??how to fix it??
wakaka



Joined: 11 Sep 2006
Posts: 27

View user's profile Send private message

PostPosted: Tue Oct 17, 2006 8:11 am     Reply with quote

just ignore me....found the problem

set_tris_b(0);
Neckruin



Joined: 17 Jan 2006
Posts: 66

View user's profile Send private message

PostPosted: Tue Oct 17, 2006 8:15 am     Reply with quote

I was just going to say that ... it's true Razz
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 17, 2006 12:31 pm     Reply with quote

Quote:
#include <16F767.h>
#use delay (clock=20000000)
#fuses HS,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,MCLR,NODEBUG,EC_IO

You have two oscillator fuses. The compiler will use the last one
in the line. The HS fuse will be ignored.

Here are the config bits created by your #fuses statement.
From the .LST file:
Quote:

Configuration Fuses:
Word 1: 3FAB EC_IO NOWDT NOPUT NOPROTECT NOBROWNOUT BORV20 MCLR CCP2C1 NODEBUG
Word 2: 3FFF FCMEN IESO BORSEN


You should only have one oscillator fuse.
wakaka



Joined: 11 Sep 2006
Posts: 27

View user's profile Send private message

PostPosted: Tue Oct 17, 2006 11:56 pm     Reply with quote

really?? i thought for PIC which has internal clock, need to define to use external clock (EC_IO), then need to define the clock speed (XT, HS)


Meaning if using external, just define XT or HS enuf??
if i only define EC_IO, and i use 4Mhz, 12Mhz, 20Mhz crystal won't matter is it?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 1:01 am     Reply with quote

Quote:

I thought for PIC which has internal clock, need to define to use external
clock (EC_IO), then need to define the clock speed (XT, HS).

To use the internal RC oscillator, use the INTRC_IO fuse setting.
Put the #use delay() statement on the next line after the #fuses
statement. Then the compiler will automatically put in code to setup
the internal oscillator to run at the specified frequency.
Code:

#include <16F767.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, BORV42, PUT
#use delay(clock=4000000)

The internal RC oscillator only runs at certain frequencies, as specified
in the 16F767 data sheet. These are 8 MHz, 4 MHz, 2 MHz, etc.
See the data sheet for the complete list.


Quote:

If i only define EC_IO, and i use 4Mhz, 12Mhz, 20Mhz crystal won't matter is it?

EC_IO is used for an external oscillator. If you have oscillators in
each of those three frequencies, then yes, you can use all of them
with the same EC_IO fuse setting. Note that this is for an oscillator,
not a crystal. See the photos below.

Here is a photo of a crystal.
http://rocky.digikey.com/WebLib/ECS/Web%20Photos/HC-49US.jpg

Here is a photo of an oscillator.
http://rocky.digikey.com/WebLib/ECS/Web%20Photos/ECS-TTL%20CLOCK%20OSCIL.jpg

EC_IO is used with the oscillator.

XT or HS are used with the type of crystal shown in the photo.
wakaka



Joined: 11 Sep 2006
Posts: 27

View user's profile Send private message

PostPosted: Wed Oct 18, 2006 5:54 am     Reply with quote

oh ya, thanks PCM, i thought crystal and oscillator is the same.....

But actually whats the difference between that 2??
What's the effect using a crystal and a oscillator?
Ttelmah
Guest







PostPosted: Wed Oct 18, 2006 6:36 am     Reply with quote

An 'oscillator', is something that oscillates!. Smile A crystal, is a component, that exhibits a narrow 'bandpass' response, which can be used to tune an oscillator to a relatively accurate frequency. The PIC itself, contains an inverting amplifier, which if attached to a suitable network, giving phase shift, will oscillate. You can use a RC network, RL network, ceramic resonator, or a crystal, to make this oscillate. A crystal "on it's own", won't oscillate, but connected with this amplifier, then forms a complete oscillator. Alternatively, you can use an 'oscillator module'. These comprise a crystal, suitable amplifier, and usually an output buffer, all assembled into a case, so if you attach power, you get a waveform out.
Now the 'LP', 'XT, and 'HS' modes for the PIC clock input, tell it to use the inverting amplifier, and set the gain for this amplifier (more gain for the 'HS' mode, and less for 'LP'). This assumes an external feedback network is going to be attached to make this oscillate. Both the input, and output connections to the amplifier are needed.
EC, means that you are going to use an external clock oscillator module. Set like this, the internal amplifier is disabled, and instead a logic output from the internal divider (clock/4), is connected to the output pin.
EC_IO, means again to use the external module, but with no output from the clock.
H4, means use the HS oscillator, but then add a *4 PLL after the oscillator (only supported in latter chips), before feeding the signal on to the internal circuitry.
RC, means configure the amplifier differently, to use a single external resistor/capacitor as an oscillator (using the resistor/capacitor as a charge nework, between two voltages, with an added FET to discharge the network, and no feedback round the amplifier).
INTRC, means to form an oscillator _inside_ the chip, using the amplifier, as in 'RC', and a resistor/capacitor, formed inside the semiconductor.
Both of these give the clock/4 output.
RC_IO, and INTRC_IO, use the same charge network, and don't give the clock/4 output, leaving the output pin available for other use.
Not all modes are available in all chips, and some have yet more complex PLL/divider options...

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