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

PCW 4.104/16F690/Vref Problem

 
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

PCW 4.104/16F690/Vref Problem
PostPosted: Sat Feb 13, 2010 10:19 pm     Reply with quote

//For the "(VREF_HIGH | 6)",
//it makes no difference if the "6" is
//1 or 15, the VREF is always 0.6 volts.
//It is the same for VREF_LOW...
//How is Vref controlled?



Code:

#include "G:\MICROCHIP-ALL\DEVELOPMENT PROGRAMS\main-3.h"


//PCW 4.104  PIC16F690
//PIC Wizard does not show #FUSE info...


void main()
{
   setup_adc_ports (NO_ANALOGS|VSS_VDD) ;
   setup_adc (ADC_CLOCK_DIV_2) ;
   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
   // TODO: USER CODE!!

setup_vref (VREF_HIGH | 6); // At VDD=5, the voltage *SHOULD BE* 2.19V

//For the "(VREF_HIGH | 6)",
//it makes no difference if the "6" is
//1 or 15, the VREF is always 0.6 volts.
//It is the same for VREF_LOW...
//How is Vref controlled?

setup_comparator(CP1_A1_VR);
output_c(0x00);

   while(TRUE)
   {
      output_bit( pin_c0, C1OUT);

   }//end while

}//end main

_________________
[email protected]
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 14, 2010 12:49 am     Reply with quote

Describe how you are testing this. How are you measuring the Vref
voltage ? How to you know it's always 0.6v ?

Is this being tested in hardware or in Proteus ?
Boyce



Joined: 07 Feb 2010
Posts: 39

View user's profile Send private message

PCW 4.104/16F690/Vref Problem
PostPosted: Sun Feb 14, 2010 1:16 am     Reply with quote

Thanks for the response.

I am running the software on hardware, Microchip's PicKit 2. A pot is set at the trip point and the voltage is read. The voltage is always 0.581 or very close to 0.6.

0.6 volts is suspicious as that the the voltage for the 16F690's fixed reference.
Thanks,
Boyce Griffith
_________________
[email protected]
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Feb 14, 2010 3:15 am     Reply with quote

You did not enable VREF for C1.
Code:
setup_vref (VREF_HIGH | VREF_COMP1 | 6);

The compiler reference doesn't tell specific details for all chips. You have to consult the Microchip datasheet or the device file.
Boyce



Joined: 07 Feb 2010
Posts: 39

View user's profile Send private message

PostPosted: Sun Feb 14, 2010 10:06 am     Reply with quote

[quote="FvM"]You did not enable VREF for C1.

Code:
setup_vref (VREF_HIGH | VREF_COMP1 | 6);


This suggestion works.

I am trying to resolve an issue with the 0.6V ref, but have not given up, yet.

Thanks for your help.
Boyce
_________________
[email protected]
Boyce



Joined: 07 Feb 2010
Posts: 39

View user's profile Send private message

PostPosted: Sun Feb 14, 2010 10:55 am     Reply with quote

There is still an issue with comparators.

Code:
  setup_vref (VREF_6th | VREF_COMP1 );  //5.10/1.27??V
  //expected 0.6 volts range for above code


The code delivered 1.27 volts to the comparator instead of the expected 0.6 volts.

Is there a way to deliver 0.6 volts using VREF_6th?

Thanks,
Boyce
_________________
[email protected]
Ttelmah
Guest







PostPosted: Sun Feb 14, 2010 11:25 am     Reply with quote

Read the data sheet.
You are misunderstanding how the bits work, and what you can do.
Section 8.1
You basically have the choice of a selection from the high range, low range, _or_ the 0.6v reference.
Then look at the registers. Look at VRCON. Note that selecting C1VREN, _overrides_ the selection of the 0.6v reference.
This is what is happening in the above.
Since you are accessing VRCON, and not selecting the high range, low range is selected, 0 is loaded as the selection, so you get basically 1/4 of the supply voltage. 5.1*0.25 = 1.275v.
If you want to use the 0.6v ref, _just select Vref_6th_. If you want to use the Vref divider, then you need to use VREF_COMP1.

Best Wishes
Boyce



Joined: 07 Feb 2010
Posts: 39

View user's profile Send private message

PostPosted: Sun Feb 14, 2010 11:40 am     Reply with quote

I was sure I had tried this before. It works. Feel a little silly...
Code:
  setup_vref (VREF_6th); //5.07/0.581V

The code I sited before appeared to be closer to what I had gotten to work.
Thanks,
Boyce
_________________
[email protected]
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