Hello I'm using PIC16F877A in my project, I need to select VREF+ and VREF- both externals and
I also need AN0 (Analog input ADC) RA1,RA2,RA3,RA4,RA5 Digital outputs.
In tables I have seen ADCON1 is "1111"
In ADC external properties,
I can select VREF+ but I can not select VREF-
I am using a load cell and I need VREF- for tare.
How can I edit my ADC component macro in order to configure it?
MACRO ADC
[Defines]
/**** Macro Substitutions ****
a = Unique Reference
b = Which ADC Channel
c = Acquisition time
d = Conversion Speed
e = VRef+ Option
f = VRef Voltage x 0.01V
******************************/
//Common Defines
#define %a_MX_ADC_CHANNEL %b
#define %a_MX_ADC_ACTIME %c
#define %a_MX_ADC_CONVSP %d
#define %a_MX_ADC_VREFOP %e
#define %a_MX_ADC_VREFVOL %f
#ifndef MX_ADC_CHANNEL_%b
#define MX_ADC_CHANNEL_%b //Inform CAL ADC channel %b is now in use.
#endif
#ifndef MX_ADC_REF //Inform CAL ADC peripheral is now in use
#define MX_ADC_REF
#endif
extern void FC_CAL_Enable_ADC (MX_UINT8 Channel, MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 T_Charge);
extern MX_UINT16 FC_CAL_Sample_ADC (MX_UINT8 Sample_Mode);
extern void FC_CAL_Disable_ADC (void);
If it is not possible, Can you give me a C code that configure ADCON1= 1111 and I would copy and paste in my flowchart.
Thanks so much, i am a beginner and using flowcode 5.
HOW TO EDIT MY ADC MADRO CODE?
- STibor
- Posts: 263
- Joined: Fri Dec 16, 2011 3:20 pm
- Has thanked: 116 times
- Been thanked: 113 times
- Contact:
Re: HOW TO EDIT MY ADC MADRO CODE?
Hi,
FlowcodeV5 close the program.
Find the PIC_CAL_ADC.c file.
C: \ Program Files \ Flowcode \ v5 \ CAL \ PIC
Look for the following line in the file:
modified:
Did not test the hardware, just the simulator!
CAL original file make a backup copy.
FlowcodeV5 close the program.
Find the PIC_CAL_ADC.c file.
C: \ Program Files \ Flowcode \ v5 \ CAL \ PIC
Look for the following line in the file:
Code: Select all
// ADC Type 1 Supported Devices
// 16F818, 16F819, 16F873A, 16F874A, 16F876A, 16F877A,
original:
#ifdef MX_ADC_TYPE_1
void FC_CAL_Enable_ADC (MX_UINT8 Channel, MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 T_Charge)
{
switch (Channel)
{
#ifdef MX_ADC_CHANNEL_0
case (0):
tris_mask = 0x01;
tris_reg = &trisa;
if (Vref == 0)
adcon1 = 0x0E;
else
adcon1 = 0x05; old value
break;
Code: Select all
#ifdef MX_ADC_TYPE_1
void FC_CAL_Enable_ADC (MX_UINT8 Channel, MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 T_Charge)
{
switch (Channel)
{
#ifdef MX_ADC_CHANNEL_0
case (0):
tris_mask = 0x01;
tris_reg = &trisa;
if (Vref == 0)
adcon1 = 0x0E;
else
adcon1.PCFG3 = 0x01;
adcon1.PCFG2 = 0x01;
adcon1.PCFG1 = 0x01;
adcon1.PCFG0 = 0x01; //adcon1 = 0x05; old value
break;
CAL original file make a backup copy.
Re: HOW TO EDIT MY ADC MADRO CODE?
STibor wrote:Hi,
FlowcodeV5 close the program.
Find the PIC_CAL_ADC.c file.
C: \ Program Files \ Flowcode \ v5 \ CAL \ PIC
Look for the following line in the file:modified:Code: Select all
// ADC Type 1 Supported Devices // 16F818, 16F819, 16F873A, 16F874A, 16F876A, 16F877A, original: #ifdef MX_ADC_TYPE_1 void FC_CAL_Enable_ADC (MX_UINT8 Channel, MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 T_Charge) { switch (Channel) { #ifdef MX_ADC_CHANNEL_0 case (0): tris_mask = 0x01; tris_reg = &trisa; if (Vref == 0) adcon1 = 0x0E; else adcon1 = 0x05; old value break;
Did not test the hardware, just the simulator!Code: Select all
#ifdef MX_ADC_TYPE_1 void FC_CAL_Enable_ADC (MX_UINT8 Channel, MX_UINT8 Conv_Speed, MX_UINT8 Vref, MX_UINT8 T_Charge) { switch (Channel) { #ifdef MX_ADC_CHANNEL_0 case (0): tris_mask = 0x01; tris_reg = &trisa; if (Vref == 0) adcon1 = 0x0E; else adcon1.PCFG3 = 0x01; adcon1.PCFG2 = 0x01; adcon1.PCFG1 = 0x01; adcon1.PCFG0 = 0x01; //adcon1 = 0x05; old value break;
CAL original file make a backup copy.
Oh my god, Thank You so much STibor, It was exactly what i needed it.
Really appreciate it.