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

#DEVICE ADC = 10-Can not change device type this far into

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



Joined: 07 Feb 2010
Posts: 39

View user's profile Send private message

#DEVICE ADC = 10-Can not change device type this far into
PostPosted: Tue Mar 09, 2010 7:07 pm     Reply with quote

Compiler PCW 4.104 Device 16F690

How is #DEVICE ADC = 10 applied?

When I put it in my code, the error
"Can not change device type this far into the code"
pops up.

What can I do to change this? Does this go in the 16F690.h file?
Thanks,
Boyce

Here is the code:
Code:
int16 T0, T2, T3;//Leave off T1 as AN1 is the reference
int Dt1, Dt2, Dt3;
 
#DEVICE ADC=10 //<<<===Error shown here...

void main()
{

   setup_adc(ADC_CLOCK_INTERNAL);
   setup_adc_ports(sAN0|sAN2|sAN3|VSS_VREF);//AN0 is the ADC voltage reference
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
   //Setup_Oscillator parameter not selected from Intr Oscillator Config tab

   for(;;)
   {
      set_adc_channel(0);//0 for AN0, 1 for AN1...
      delay_us(10);
      T0 = make8((read_adc()),0);
     
      //REMEMBER, AN1 IS THE REFERENCE ON A 16F690

      set_adc_channel(2);//0 for AN0, 1 for AN1...
      delay_us(10);
      T2 = make8((read_adc()),0);

      output_C(T2);//Output lower 8 bits of T2

      //output_C(T1-T2)

   }//end for(;;)

}//end main

_________________
boyceg1@gmail.com
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 09, 2010 8:10 pm     Reply with quote

Put all #device statements immediately after the #include line for the PIC.
That's what it means.
Boyce



Joined: 07 Feb 2010
Posts: 39

View user's profile Send private message

PostPosted: Tue Mar 09, 2010 11:43 pm     Reply with quote

Or put it in the 16F690.h file were the #device adc = 8 is. Change the 8 to 10. Works.

Thanks for the suggestion.
Boyce
_________________
boyceg1@gmail.com
LostInSpace



Joined: 09 Mar 2010
Posts: 13

View user's profile Send private message

PostPosted: Wed Mar 10, 2010 12:13 am     Reply with quote

The downside of changing supplied .h files is that with a new compiler install you will overwrite your modifications and your code may not work as expected. Or another programmer might not get your modified .h file.

If you do this (see snippet below) it will work and be in your main .c file so that everyone will know what is happening.

// Device setup
#include <16F688.h>
#device *=16
#device adc=8

// Fuses, etc.
#FUSES WDT
.
.
.

HTH - My 2 cents worth.
Boyce



Joined: 07 Feb 2010
Posts: 39

View user's profile Send private message

PostPosted: Wed Mar 10, 2010 7:11 pm     Reply with quote

Sorry, I was mistaken when I said #DEVICE ADC = 10 was in the 16F690.h file.

Actually, it is in the main.h file. The main.h file contains the following:
Code:
#include <16F690.h>
#device adc=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOCPD                    //No EE protection
#FUSES NOPUT                    //No Power Up Timer
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES RESERVED                 //Used to set the reserved FUSE bits

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)


I don't think PCW 4.104 will let me put #DEVICE in the main.c file at all. Been wrong before.
Boyce
_________________
boyceg1@gmail.com
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