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

missing fuse? CCS too old? -- Thanks [solved]

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



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

missing fuse? CCS too old? -- Thanks [solved]
PostPosted: Fri Jun 01, 2012 6:40 am     Reply with quote

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
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Fri Jun 01, 2012 6:43 am     Reply with quote

found this....
http://www.ccsinfo.com/forum/viewtopic.php?t=17386&highlight=intio2+16f88

ill try this..
INTRC_IO

but... in that post... the last comment points out SPI stopped working... my project relies heavily on SPI....

ill post my findings....
_________________
CCS PCM 5.078 & CCS PCH 5.093
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jun 01, 2012 8:11 am     Reply with quote

If you can't find the correct 'fuses' within the compiler, you can always set them using MPLAB....and override the program setup.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Fri Jun 01, 2012 8:39 am     Reply with quote

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
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jun 01, 2012 9:35 am     Reply with quote

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
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Fri Jun 01, 2012 10:11 am     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 01, 2012 12:50 pm     Reply with quote

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.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Fri Jun 01, 2012 4:21 pm     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 01, 2012 8:05 pm     Reply with quote

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.
Ttelmah



Joined: 11 Mar 2010
Posts: 19337

View user's profile Send private message

PostPosted: Sat Jun 02, 2012 2:31 am     Reply with quote

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
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Sat Jun 02, 2012 8:01 am     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19337

View user's profile Send private message

PostPosted: Sat Jun 02, 2012 1:50 pm     Reply with quote

The instruction cycle, is always clock/4. No difference between internal/external.

Best Wishes
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Mon Jun 04, 2012 7:17 am     Reply with quote

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