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

PIC16F1703 no system clock??? data sheet & compiler wron

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



Joined: 21 Mar 2014
Posts: 12

View user's profile Send private message

PIC16F1703 no system clock??? data sheet & compiler wron
PostPosted: Thu Sep 18, 2014 2:53 pm     Reply with quote

Gang,

So I have a new project and it's a basic IO stuff for an audio project. I am a little confused about the fuses and the data sheet on the PIC16F1703.

First there are no fuses for INTOSC in the code or the list of available options or even any of the FOSC options for that matter.

I build basically the following here:

Code:
#include <16F1703.h>
#device ADC=16
#device ICD=TRUE

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES MCLR                     // MCLR used for reset
#FUSES NOCLKOUT                 // no clock output
#FUSES NOPLLEN                  // enable PLL in software
#FUSES NOPUT                    // no power up timer
#FUSES WDT_SW                   //No Watch Dog Timer, enabled in Software
#FUSES BROWNOUT                 // enable brown out
#FUSES BORV25                   //Brownout reset at 2.5V
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#device ICD=TRUE
#use delay(clock=1000000)
#use FIXED_IO( C_outputs=PIN_C3,PIN_C2,PIN_C1,PIN_C0 )

void main()
{

setup_oscillator(OSC_1MHZ|OSC_INTRC|OSC_PLL_OFF,0);
set_tris_a(TRIS_PORTA);
set_tris_c(TRIS_PORTC);

~~~

I use the ICD-64 it programs the device in the debugger, but halts immediately saying it's not getting a system clock.

Ok look at the data sheet which is wrong as well. It states in the Config bits section that there is bits 0:1 to select the oscillator of choice which only accounts for the external oscillators.

In the Oscillator section under Internal that sections states that FOSC is 0:1:2 and to set the INTOSC option for using the internal oscillator.

Ok, anyone have the answer? I have a feeling that the config section is wrong as it has bit 2 of Config 1 as unimplemented. YEP there's the problem... If I look at the PIC16F1825 bits 0-2 are FOSC and I need those set to 100 binary for INTOSC.

Guys can someone tell me how to fix this?

Thanks,
Gordon
_________________
J. Gordon Rankin
Wavelength Audio, ltd.
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Sep 18, 2014 6:30 pm     Reply with quote

Are you on the latest version of the compiler?

On 5.028 the setup looks OK to me.
_________________
Google and Forum Search are some of your best tools!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 18, 2014 7:46 pm     Reply with quote

Try forcing the fuses to use the internal oscillator. Comment out your
fuses and substitute these two lines:
Code:
#fuses 1=0x39e0
#fuses 2=0x0AFF

These two lines are the Config words produced by your existing program
when compiled with vs. 5.028, except that I zeroed out the lowest 3 bits
of Config Word 1. If the internal oscillator exists and if it can be enabled,
zeroing those 3 bits should turn it on.

I agree the 16F1703 data sheet shows no internal oscillator in the Config
bits settings. But maybe it's a typo by Microchip.
Ttelmah



Joined: 11 Mar 2010
Posts: 19339

View user's profile Send private message

PostPosted: Fri Sep 19, 2014 1:35 am     Reply with quote

I think the first thing to do, is to point it out to Microchip.
There is a severe problem in the data sheet, and CCS have based their code, on what this shows....

On trying the fuses, you may need a slightly different pattern from what PCM_programmer has given.
Unlike most chips, the pattern required to run from the internal oscillator, seems to require Fosc<2,0> = 100, to enable the PRIMUX bit. So 0x39E4, not E0. Tried compiling this, and importing into MPLAB, and it appears to be right. However I'd then suggest setting the SCS bits with setup_oscillator as soon as the chip has booted:

setup_oscillator(OSC_1MHZ|OSC_NORMAL);

The only pattern that enables PRIMUX, is Fosc<2,0>=100, and SCS=00. SCS, wakes as 00, so this should be right already.

Cross anatomical components.....
ufarooq



Joined: 24 Jul 2014
Posts: 7

View user's profile Send private message

PostPosted: Fri Sep 19, 2014 3:52 am     Reply with quote

Yes, it is typo in datasheet in this regard. But, also beware that the header file provided by CCS for this family doesn't have allowance for peripheral select option. I haven't heard back from either Microchip or CCS regarding my complaints thus far.

A way around can be to download embedded code configurator plugin for MPLAB X and extract the relevant code from there.
_________________
Umer
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