View previous topic :: View next topic |
Author |
Message |
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
16F676 - Internal Oscillator ONLY (SOLVED) |
Posted: Tue Jul 26, 2011 3:40 am |
|
|
I started doing for myself one simple device PIC16F676. In the scheme I am using crystal at 14MHz.
I write in the title of "# FUSES HS." Programs the controller, install it into the card, turn on the power ... and nothing happens! With the help of an oscilloscope to look quartz - 0 volts there. I begin to understand - in the HEX file is installed Internal OSC!
v4.120
Last edited by Eddy71ua on Wed Jul 27, 2011 3:33 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Tue Jul 26, 2011 11:48 am |
|
|
How are you programming the chip?.
On many packages, there is an option as to whether the fuses in the code are used. On MPLAB for example, there is a tick box, specifying whether the fuses in the code are used, or the ones set manually. Most programmer packages offer the same option. 4.120, with #fuses HS near the top of the code (not in the title?), does select the HS oscillator on the 16F676 correctly. The fuses selected by the code, can be seen by looking at the end of the .lst fle.
Best Wishes |
|
|
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
|
Posted: Tue Jul 26, 2011 1:03 pm |
|
|
Code: |
#include <16F676.h>
#fuses HS, WDT, NOPROTECT, NOMCLR
#use delay(clock = 14000000)
...
|
In other projects it works ..
In this project the resulting file all times is on the internal oscillator. I tested chis code on three different programmers. Olway "IntOSC". Magic.. |
|
|
RckRllRfg
Joined: 20 Jul 2011 Posts: 60
|
A bit more control of the Oscillator.... |
Posted: Tue Jul 26, 2011 2:11 pm |
|
|
Hi Eddy71ua -
Oddly, I had to deal with a similar issue last week. Found that my external oscillator was not working and had to switch to the internal one.
I left the fuse as "HS". I did not add or remove any other fuses.
I used this command at the beginning of my main(void) :
Code: | setup_oscillator(OSC_16MHZ); |
I am using a different PIC, so the line of code that I am giving as an example may not work on your PIC. You can determine which internal oscillator modes are support on your PIC by looking at the .h file provided in C:\Program Files\PICC\Devices
Hope this helps -
RckRllRfg |
|
|
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
|
Posted: Tue Jul 26, 2011 2:59 pm |
|
|
From 16F676.h:
Quote: |
//////// Standard Header file for the PIC16F676 device ////////////////
#device PIC16F676
#nolist
//////// Program memory: 1024x14 Data RAM: 64 Stack: 8
//////// I/O: 12 Analog Pins: 8
//////// Data EEPROM: 128
//////// C Scratch area: 20 ID Location: 2000
//////// Oscilator Calibration Address: 90
//////// Fuses: LP,XT,HS,EC_IO,INTRC_IO,INTRC,RC_IO,RC,NOWDT,WDT,PUT,NOPUT
//////// Fuses: NOMCLR,MCLR,NOBROWNOUT,BROWNOUT,PROTECT,NOPROTECT,CPD,NOCPD
|
I think this is a bug in the compiler. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 26, 2011 3:16 pm |
|
|
It worked for me. I installed vs. 4.120 and compiled the test program
shown below:
Code: |
#include <16F676.h>
#fuses HS, WDT, NOPROTECT, NOMCLR
#use delay(clock = 14000000)
//===========================
void main()
{
while(1);
}
|
At the end of the .LST file, it gives the configuration word:
Quote: |
Configuration Fuses:
Word 1: 3FCA HS WDT PUT NOMCLR BROWNOUT NOPROTECT NOCPD |
Look at the Special Features / Configuration Data section of the 16F676
data sheet. The bottom 3 bits of the Config word are the oscillator bits.
These are 010 for the word above. That's the HS fuse. It's correct.
Also, in MPLAB I go to Configure / Select Device and set it for 16F676.
Then I compile and look at Configure / Configuration bits. It also says:
Code: |
Address Value Field Category Setting
2007 3FCA Fosc Osc selection bits HS
|
It's working. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Tue Jul 26, 2011 3:20 pm |
|
|
Simple answer, is always to look at the tail of the .LST file, where the actual bit patterns being generated for the fuses are shown. Check them with the data sheet.
So:
Code: |
Configuration Fuses:
Word 1: 3FF2 HS NOWDT NOPUT MCLR BROWNOUT NOPROTECT NOCPD
|
As you can see I have selected a couple of other fuses as well, but the bit pattern for HS, is the bottom two bits of the word, and should be '10', for HS, which is correct for me.
Best Wishes |
|
|
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
|
Posted: Wed Jul 27, 2011 12:56 am |
|
|
main.lst
Quote: |
.................... #include <16F676.h>
.................... //////// Standard Header file for the PIC16F676 device
.................... #device PIC16F676
.................... #list
.................... #device adc=10
.................... #FUSES WDT, HS, NOMCLR, BROWNOUT, PROTECT
.................... #use delay(int=14318180,RESTART_WDT)
......
Configuration Fuses:
Word 1: 3F4C INTRC_IO WDT PUT NOMCLR BROWNOUT PROTECT NOCPD
|
Magic.. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Wed Jul 27, 2011 2:43 am |
|
|
Multiple things:
1) Remove the device PIC16F676 line - this is already set when you include the devices .h file.
2) The problem is in your clock statement. what do you think the keyword 'int' implies?. You are overriding the fuses.....
It was funny, as so often, PCM programmer and myself both went away and tried a compilation yesterday afternoon, with the same 'it works' result for both of us.
Best Wishes |
|
|
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
|
Posted: Wed Jul 27, 2011 3:32 am |
|
|
You are a genius!
Code: |
#use delay(crystal=14318180,RESTART_WDT)
.....
Configuration Fuses:
Word 1: 3F4A HS WDT PUT NOMCLR BROWNOUT PROTECT NOCPD
|
Thank you very much!
|
|
|
|