View previous topic :: View next topic |
Author |
Message |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
missing fuse? CCS too old? -- Thanks [solved] |
Posted: Fri Jun 01, 2012 6:40 am |
|
|
Hi,
I'm using a very old compiler "3.early"
I'm trying to program a 16F88 using the internal oscillator so that i may use the oscillator pins A6 and A7 as Digital I/O.
But looking at the .h File I only see LP, XT, HS, EC_IO.
looking at the datasheet I see that I'm missing INTIO1 &2
How can I go about setting this up? Since there is no provision in my .h file I assume CCS didn't support this at the time.
I know I can do it via #ASM but... i ... forgot.... Assembler....... well, I'm very rusty. I can brush up but i don't know how to include ASM code in my header.
I tried everything I could, even programing the fuses separately with MPLAB... but I can't even blink a LED and thus get on with my project.
So... I ask your guidance. _________________ CCS PCM 5.078 & CCS PCH 5.093
Last edited by Gabriel on Mon Jun 04, 2012 7:17 am; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Fri Jun 01, 2012 8:11 am |
|
|
If you can't find the correct 'fuses' within the compiler, you can always set them using MPLAB....and override the program setup. |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri Jun 01, 2012 8:39 am |
|
|
I tried..didn't work, I set my programmer to manual, and set to program the config bits only... then manually set the config bits, and de-selected "fuses from program".
Maybe I did it wrong?
g _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Fri Jun 01, 2012 9:35 am |
|
|
I use MPLAB for the IDE, Picstart Plus as the programmer, never had a problem in 20+ years...
Did you 'remark out' or delete the 'fuses options...' line in your program ?
Jay |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri Jun 01, 2012 10:11 am |
|
|
yes i did...
i commented out my #Fuses line...
ill give it one more try tonight...
however im not quite sure what to put in my:
Code: | #use Delay (clock=????) |
by setting INTIO2 am i by default at 8MHz and thus i should do:
Code: | #use Delay (clock=8000000) |
???
Edit:
I should mention that i program on the CCS IDE and then simply import the hex file to MPLAB for programing... and then tried to set the fuses on mplab.. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 01, 2012 12:50 pm |
|
|
Quote: | I'm using a very old compiler "3.early"
|
Why not post your exact version ? It's given at the top of the .LST file. |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri Jun 01, 2012 4:21 pm |
|
|
3.155.....
I didn't specify before because usually I post at the office and I don't have ccs there.... and i frankly didn't remember the number.
I just remember it was 3. something.
anyways... hope this helps. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 01, 2012 8:05 pm |
|
|
If your compiler version doesn't correctly support all the Config Bits,
you can do it manually with the two #rom statements shown below.
Use those lines instead of the #fuses statement.
Code: |
#include <16F88.H>
#rom 0x2007 = {0x3F70}
#rom 0x2008 = {0x3FFF}
#use delay(clock=4000000)
//==========================
void main()
{
while(1);
} |
Those two lines will give you the same thing in vs. 3.155 as these lines
do for a modern compiler, vs. 4.132:
Code: |
#fuses INTRC_IO,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
|
If you want to use different settings, you can print out the Config Bits
pages in the 16F88 data sheet and write in the 1's and 0's for your
desired Config bits. Then convert the 14-bit number to a 16-bit hex
value (right justified) and insert it in the two #rom statements as shown
above. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Sat Jun 02, 2012 2:31 am |
|
|
And just to round things off, you must set the 'clock' statement to match the actual oscillator frequency selected, which will depend on the 3bit value written to the OSCCON register bits 6:4.
So (for 8MHz), do something like:
Code: |
#include <16F88.H>
#rom 0x2007 = {0x3F70}
#rom 0x2008 = {0x3FFF}
#use delay(clock=8000000)
#byte OSCCON = 0x8F
//==========================
void main() {
//Now need to set OSCCON to give 8MHz
OSCCON=(OSCCON & 0xF) | 0x70;
while(1);
}
|
The default bit pattern for OSCCON, is 000 for the three clock control bits, so the default frequency is 31.25KHz. In the later compilers, if the INT_RC fuse is selected, and the clock rate matches one possible from this source, these bits are automatically set.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Sat Jun 02, 2012 8:01 am |
|
|
you guys are AWESOME!
I further tested setting the Fuses with MPLAB as separatedly and actually got it to work as Temtronic suggested (thanks!)
however, i could not get the clock/delay values to match. i had no idea what frequency or clock i was using...
so doing "~accurate" blinky led was impossible, and i also noticed that the frequency varied with voltage... low voltage, low speed, higher voltage higher speed... so i concluded i was using the RC clock... however i had selected INTIO2... so i have no idea what is going on.
anyways... Ttelmah and PCM, thank you for your accurate and clear solutions...as always.
you answered both my questions before i had a chance to ask them!
just so that i am clear.... the internal oscilator (INTIO1&2) should not vary with input voltage right?
EDIT:
When in 8MHz mode, my "actual"clock is 8MHz? or is it effectivly 2 MHz?.... they way i understand it is that this internal clock is not divided by 4 as a 20MHz crystal on a 16F877A would be...
so:
-16F88 @internal 8MHz osc= 8Mips
-16F877A@ External 20MHz crystal = 5Mips
That would imply a 3Mip Gain!?!? is this correct?
Thanks!
G... _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19372
|
|
Posted: Sat Jun 02, 2012 1:50 pm |
|
|
The instruction cycle, is always clock/4. No difference between internal/external.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Jun 04, 2012 7:17 am |
|
|
Hi All,
First off, Thanks to all who helped me out!
i can now run code on my board! (at the desired clock)
and i learned a new trick as well:
Code: | #byte OSCCON = 0x8F
//==========================
void main() {
//Now need to set OSCCON to give 8MHz
OSCCON=(OSCCON & 0xF) | 0x70; |
It never occured to me to set the registers like this... or that it could be so simple....
i have a new problem now... ADC is not quite working... but ill post that on a diferent thread.
Thanks again.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
![](templates/subSilver/images/spacer.gif) |
|