Vous êtes sur la page 1sur 13

Programação do PIC 16F877 1

Programa principal:
// D:\UPF\Placa_Aq_Paralela\Placa Mônica\Programação PIC\mnca_pic.c
//control bits(entrada):
// PIN_D0 = indica recebimento de comando
// PIN_D1 = receber(1) ou enviar(0)
// PIN_D2 = mandar segundo bit
//data out bits: PIN_D3 -> PIN_D7

/* Já testado para funções analógicas e pwm*/

#include <16F877.h>
#include <math.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOBROWNOUT,NOLVP

#use FAST_IO(B)
#use FAST_IO(C)
#use FAST_IO(D)
#use FAST_IO(E)

#byte port_b = 0x06


#byte port_c = 0x07
#byte port_d = 0x08

/************************************************************************************************/

void func_receber(int num_port) {


long int data;
int num_port1;
if (num_port == 2)
{num_port1 = 3;}
else
{ num_port1 = num_port; }
set_adc_channel(num_port1);
delay_ms(20);
data = read_adc();
output_bit(PIN_D3, data & 1);
output_bit(PIN_D4, (data & 2)/2);
output_bit(PIN_D5, (data & 4)/4);
output_bit(PIN_D7, (data & 8)/8);
output_bit(PIN_D6, 1); //sinaliza OK 1

while ( (port_d & 7) != 2 ) //espera segundo sinal


{ }

output_bit(PIN_D3, (data & 16)/16);


output_bit(PIN_D4, (data & 32)/32);
output_bit(PIN_D5, (data & 64)/64);
output_bit(PIN_D7, (data & 128)/128);
output_bit(PIN_D6, 0); // sinaliza OK 2

while ( (port_d & 7) != 3 ) //espera terceiro sinal


{ }

output_bit(PIN_D3, (data & 256)/256);


output_bit(PIN_D4, (data & 512)/512);
output_bit(PIN_D6, 1); // sinaliza OK 3

} // fim func_receber

/************************************************************************************************/

void func_enviar(int num_port) {


int i,data_low,data_high;
int bit_serial = 16;
int valorDA = 0;

output_high(PIN_D6); // sinaliza OK 1

while ( (port_d & 7) != 2 ) //espera segundo sinal


{ }

data_low = port_b & 31;


output_low(PIN_D6); // sinaliza OK 2

while ( (port_d & 7) != 3 ) //espera terceiro sinal


{ }

data_high = port_b & 31;

if (num_port == 2) {
output_low(PIN_C3); //baixar clock do A/D 1
output_low(PIN_C0); //baixar CS d/a 1
for(i=12; i>0 ; i--)
{
Programação do PIC 16F877 2
if (i >= 8)
{
valorDA = (data_high & bit_serial);
}
else if (i >= 3)
{
if (i == 7) { bit_serial = 16;}
valorDA = (data_low & bit_serial);
}
else
{
valorDA = 0;
}
bit_serial = bit_serial / 2;
output_low(PIN_C3); //baixar clock do a/d 1
output_bit(PIN_E2,valorDA);
output_high(PIN_C3); //fim do pulso
}
output_low(PIN_C3);
output_high(PIN_C0); //ativar CS D/A 1
}

else if (num_port == 1) {
output_low(PIN_C5); //baixar clock do A/D 1
output_low(PIN_C4); //baixar CS d/a 1
for(i=12; i>0 ; i--)
{
if (i >= 8)
{
valorDA = (data_high & bit_serial);
}
else if (i >= 3)
{
if (i == 7) { bit_serial = 16;}
valorDA = (data_low & bit_serial);
}
else
{
valorDA = 0;
}
bit_serial = bit_serial / 2;

output_low(PIN_C5); //baixar clock do a/d 1


output_bit(PIN_E2,valorDA);
output_high(PIN_C5); //fim do pulso
}
output_low(PIN_C5);
output_high(PIN_C4); //ativar CS D/A 1
}

else if (num_port == 0) {
output_low(PIN_C7); //baixar clock do A/D 1
output_low(PIN_C6); //baixar CS d/a 1
for(i=12; i>0 ; i--)
{
if (i >= 8)
{
valorDA = (data_high & bit_serial);
}
else if (i >= 3)
{
if (i == 7) { bit_serial = 16;}
valorDA = (data_low & bit_serial);
}
else
{
valorDA = 0;
}
bit_serial = bit_serial / 2;
output_low(PIN_C7); //baixar clock do a/d 1
output_bit(PIN_E2,valorDA);
output_high(PIN_C7); //fim do pulso
}
output_low(PIN_C7);
output_high(PIN_C6); //ativar CS D/A 1
}

output_high(PIN_D6); // sinaliza OK 3

} // fim fun_enviar
/***********************************************************************/
void func_enviar_digital(int num_port) {
int valor;
if (port_b & 16) {valor = 1;}
else {valor = 0; }
switch (num_port) {
case 0: output_bit(PIN_E1,valor);
break;
case 1: output_bit(PIN_E0,valor);
Programação do PIC 16F877 3
break;
default:
}; // end switch
output_high(PIN_D6); // sinaliza OK 1
}//fim func_enviar_digital
/************************************************************************************************/

void func_receber_digital(int num_port) {


int exit_dig;
switch (num_port) {
case 2: exit_dig = input(PIN_A5);
break;
case 3: exit_dig = input(PIN_A4);
break;
case 4: exit_dig = input(PIN_A2);
break;
default:
} // end switch
output_bit(PIN_D3,exit_dig); //indica valor(0/1) da saida digital desejada

output_high(PIN_D6); // sinaliza OK 1
}//fim func_receber_digital
/************************************************************************************************/

void func_pwm_duty (int num_port) {


long int duty,max;
int resolution;
long int data_low,data_high;
long int duty_cycle;

output_high(PIN_D6); // sinaliza OK 1

while ( (port_d & 7) != 2 ) //espera segundo sinal


{ }

data_low = port_b & 31;

output_low(PIN_D6); // sinaliza OK 2

while ( (port_d & 7) != 3 ) //espera terceiro sinal


{ }

data_high = port_b & 31;


duty_cycle = (data_low + 32*data_high);

if (num_port == 0) {
set_pwm1_duty(duty_cycle); // define duty-cycle 1
}
else if (num_port == 1) {
set_pwm2_duty(duty_cycle); // define duty-cycle 2
}

output_high(PIN_D6); // sinaliza OK 3

} // fim func_pwm_duty

/************************************************************************************************/

void func_pwm_freq(int tipo) {


int div_fr;
output_high(PIN_D6); // sinaliza OK 1

while ( (port_d & 7) != 2 ) //espera segundo sinal


{ }

div_fr = port_b;

if (tipo == 0) {
setup_timer_2(T2_DIV_BY_1,div_fr,1);
}
else if (tipo == 1) {
setup_timer_2(T2_DIV_BY_4,div_fr,1);
}
else if (tipo == 2) {
setup_timer_2(T2_DIV_BY_16,div_fr,1);
}

output_low(PIN_D6); // sinaliza OK 2

} // fim func_pwm_freq
/************************************************************************************************/

main() {
int num_port;

SET_TRIS_A(0xFF); //port_a como entrada


SET_TRIS_B(0xFF); //RB0-RB7 entrada digital
Programação do PIC 16F877 4
SET_TRIS_C(0x00); //RC0-RC7 saida digital
SET_TRIS_D(0x07); //RD0-RD2 entrada digital, RD3-RD7 saida digital
SET_TRIS_E(0x00); //PSPMODE = 0, RE0, RE1 saidas digitais // RE2 saida digitais

setup_ccp1(CCP_PWM); // 20Mhz / (4*1*(249+1)) = 20Khz


setup_ccp2(CCP_PWM);
setup_timer_2(T2_DIV_BY_4,249,1); // define prescaler, postscaler e PR2

setup_adc_ports(RA0_RA1_RA3_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
SET_ADC_CHANNEL(0); //Usa conversão do pino RA0

set_pwm1_duty(0); //pwm desligado


set_pwm2_duty(0); //pwm desligado

output_high(PIN_C0); //CS do D/A numero 2


output_high(PIN_C4); //CS do D/A numero 1
output_high(PIN_C6); //CS do D/A numero 0
output_low(PIN_D6); // manter ACK baixo
output_low(PIN_E2);

while (TRUE) {

if ( (port_d & 7) == 1 ) { // sinaliza recebimento de comando

num_port = (port_b & 224)/32; // numero da porta

switch (port_b & 15) { // pode-se ter até 16 funções diferentes

case 0: func_enviar(num_port);
break;
case 1: func_receber(num_port);
break;
case 2: func_pwm_duty(num_port);
break;
case 3: func_pwm_freq(num_port);
break;
case 4: func_enviar_digital(num_port);
break;
case 5: func_receber_digital(num_port);
break;
default: break;
}

while ( (port_d & 7) != 7 ) // espera sétimo sinal = FIM


{ }
output_low(PIN_D6); // sinaliza OK 7 (FIM)

} // end if 1

} // end while

// D:\UPF\Placa_Aq_Paralela\Placa Mônica\Programação PIC\Math.h


////////////////////////////////////////////////////////////////////////////
//// (C) Copyright 1996,1997 Custom Computer Services ////
//// This source code may only be used by licensed users of the CCS C ////
//// compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, reproduction ////
//// or distribution is permitted without written permission. ////
//// Derivative programs created using this software in object code ////
//// form are not restricted in any way. ////
////////////////////////////////////////////////////////////////////////////

#define SQRT2 1.41421356


#define TWOBYPI 0.6366197724

float const ps[4] = {5.9304945, 21.125224, 8.9403076, 0.29730279};


float const qs[4] = {1.0000000, 15.035723, 17.764134, 2.4934718};

#define PIDIVBYTWO 1.57079633

float const pas[3] = {0.49559947, -4.6145309, 5.6036290};


float const qas[3] = {1.0000000, -5.5484666, 5.6036290};
Programação do PIC 16F877 5

int const pibytwo[6] = {0x92, 0x1F, 0xB5, 0x44, 0x42, 0xD1};

float const sintable[5] = {2.75573192E-6, -1.98412698E-4, 8.33333333E-3,


-1.66666667E-1, 1.00000000};
float const costable[5] = {2.48015873E-5, -1.38888889E-3, 4.16666667E-2,
-5.00000000E-1, 1.00000000};

/* coefficients in series expansion for sine and cosine in


reverse order */

float sqrt(float x)
{
float y, res, r;
int n;

y = x;
*(&y) = 0x7E;
if (y >= 0.9994)
res = 0.5 + 0.5*y;
else
{
res = ps[0]*y + ps[1];
res = res*y + ps[2];
res = res*y + ps[3];

r = qs[0]*y + qs[1];
r = r*y + qs[2];
r = r*y + qs[3];

res = res/r;
}

n = *(&x);
*(&res) = (n + 1)/2 + 63;
if (n & 1)
res = res/SQRT2;

return(res);
}

/***********************************************************/
float SIN_COS(float x, unsigned int shift)
{
float f, p, r, rs, *a;
long n;
int i, j;

short neg = 0;

if (x < 0.0)
{
x = -x;
if (!shift)
neg = 1;
}

f = x*TWOBYPI;
n = (long)(f > 0 ? f+0.5 : f-0.5);
f = (float)n;
r = x - f;

i = 0;
p = (float)pibytwo[0];
f = f/256.0;
r -= f*p;

i = 1;
Programação do PIC 16F877 6
p = (float)pibytwo[1];
f = f/256.0;
r -= f*p;

i = 2;
p = (float)pibytwo[2];
f = f/256.0;
r -= f*p;

i = 3;
p = (float)pibytwo[3];
f = f/256.0;
r -= f*p;

i = 4;

p = (float)pibytwo[4];
f = f/256.0;
r -= f*p;

shift += (unsigned int)(n & 0x3);

if (shift & 0x1) {


for (j = 0; j < 4; j++)
{
rs = costable[j];
rs = rs*r*r + costable[j+1];
}
}
else {

for (j = 0; j < 4; j++)


{
rs = sintable[j];
rs = rs*r*r + sintable[j+1];
}
}

if (!(shift & 0x1))


r = rs*r; // r = sin(r)
else
r = rs; // r = cos(r)

f = ((shift & 0x2) ? -r : r);

if (neg)
return -f;

else
return f;
}

float sin(float x)
{
return(SIN_COS(x, 0));
}

float cos(float x)
{
return(SIN_COS(x, 1));
}

float tan(float x)
{
float c, s;
Programação do PIC 16F877 7
c = SIN_COS(x, 1);
s = SIN_COS(x, 0);
if (c != 0.0)
return(s/c);
return(1.0e+36);
}

float ASIN_COS(float x, int n)


{
float y, res, r;
int s;

s = 0;
y = x;

if (x < 0)
{
s = 1;
y = -y;
}

if (y > 0.5)
{
y = sqrt((1.0 - y)/2.0);
n += 2;
}

res = pas[0]*y*y + pas[1];


res = res*y*y + pas[2];

r = qas[0]*y*y + qas[1];
r = r*y*y + qas[2];

res = y*res/r;

if (n & 2) // |x| > 0.5


res = PIDIVBYTWO - 2.0*res;
if (s)
res = -res;
if (n & 1) // take arccos
res = PIDIVBYTWO - res;

return(res);
}

float asin(float x)
{
float r;

r = ASIN_COS(x, 0);
return(r);
}

float acos(float x)
{
float r;

r = ASIN_COS(x, 1);
return(r);
}

/************************************************************/

float const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457};


float const qat[4] = {1.0000000, 11.368190, 28.982246, 19.818457};
Programação do PIC 16F877 8

float atan(float x)
{
float y, res, r;
int s, flag;

s = 0;
flag = 0;
y = x;

if (x < 0)
{
s = 1;
y = -y;
}

if (y > 1.0)
{
y = 1.0/y;
flag = 1;
}

res = pat[0]*y*y + pat[1];


res = res*y*y + pat[2];
res = res*y*y + pat[3];

r = qat[0]*y*y + qat[1];
r = r*y*y + qat[2];
r = r*y*y + qat[3];

res = y*res/r;

if (flag) // for |x| > 1


res = PIDIVBYTWO - res;
if (s)
res = -res;

return(res);
}

/***********************************************************/

float CEIL_FLOOR(float x, int n)


{
float y, res;
long l;
int s;

s = 0;
y = x;

if (x < 0)
{
s = 1;
y = -y;
}

if (y <= 32768.0)
res = (float)(long)y;

else if (y < 10000000.0)


{
l = (long)(y/32768.0);
y = 32768.0*(y/32768.0 - (float)l);
res = 32768.0*(float)l;
res += (float)(long)y;
}
Programação do PIC 16F877 9

else
res = y;

y = y - (float)(long)y;

if (s)
res = -res;

if (y != 0)
{
if (s == 1 && n == 0)
res -= 1.0;

if (s == 0 && n == 1)
res += 1.0;
}
if (x == 0)
res = 0;

return (res);
}

float floor(float x)
{
float r;
r = CEIL_FLOOR(x, 0);
}

float ceil(float x)
{
float r;
r = CEIL_FLOOR(x, 1);
}

/***********************************************************/

#define LN2 0.6931471806

float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093,


0.0554965651, 0.240227138, 0.693147172};

float exp(float x)
{

float y, res, r;
signed int n;
int s;

n = (signed int)(x/LN2);
s = 0;
y = x;

if (x < 0)
{
s = 1;
n = -n;
y = -y;
}

res = 0.0;
*(&res) = n + 0x7F;

y = y/LN2 - (float)n;

r = pe[0]*y + pe[1];
r = r*y + pe[2];
Programação do PIC 16F877 10
r = r*y + pe[3];
r = r*y + pe[4];
r = r*y + pe[5];

res = res*(1.0 + y*r);

if (s)
res = 1.0/res;
return(res);
}

/************************************************************/

float const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};


float const ql[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};

float log(float x)
{
float y, res, r;
signed n;

y = x;
if (y != 1.0)
{
*(&y) = 0x7E;

y = (y - 1.0)/(y + 1.0);

res = pl[0]*y*y + pl[1];


res = res*y*y + pl[2];
res = res*y*y + pl[3];

r = ql[0]*y*y + ql[1];
r = r*y*y + ql[2];
r = r*y*y + ql[3];

res = y*res/r;

n = *(&x) - 0x7E;

if (n<0)
r = -(float)-n;
else
r = (float)n;

res += r*LN2;
}

else
res = 0.0;

return(res);

#define LN10 2.30258509

float log10(float x)
{
float r;

r = log(x);
r = r/LN10;
return(r);
}

// D:\UPF\Placa_Aq_Paralela\Placa Mônica\Programação PIC\16f877.h


//////// Standard Header file for the PIC16F877 device ////////
Programação do PIC 16F877 11
#device PIC16F877
#nolist
/////////////////////////////// I/O definitions for INPUT() and OUTPUT_xxx()
#define PIN_A0 40
#define PIN_A1 41
#define PIN_A2 42
#define PIN_A3 43
#define PIN_A4 44
#define PIN_A5 45

#define PIN_B0 48
#define PIN_B1 49
#define PIN_B2 50
#define PIN_B3 51
#define PIN_B4 52
#define PIN_B5 53
#define PIN_B6 54
#define PIN_B7 55

#define PIN_C0 56
#define PIN_C1 57
#define PIN_C2 58
#define PIN_C3 59
#define PIN_C4 60
#define PIN_C5 61
#define PIN_C6 62
#define PIN_C7 63

#define PIN_D0 64
#define PIN_D1 65
#define PIN_D2 66
#define PIN_D3 67
#define PIN_D4 68
#define PIN_D5 69
#define PIN_D6 70
#define PIN_D7 71

#define PIN_E0 72
#define PIN_E1 73
#define PIN_E2 74

/////////////////////////////// Useful defines


#define FALSE 0
#define TRUE 1

#define BYTE int


#define BOOLEAN short int

#define getc getch


#define getchar getch
#define puts(s) {printf(s); putchar(13); putchar(10);}
#define putc putchar

/////////////////////////////// Constants used for RESTART_CAUSE()


#define WDT_FROM_SLEEP 0
#define WDT_TIMEOUT 8
#define MCLR_FROM_SLEEP 16
#define NORMAL_POWER_UP 24
/////////////////////////////// Constants used for SETUP_COUNTERS()
#define RTCC_INTERNAL 0
#define RTCC_EXT_L_TO_H 32
#define RTCC_EXT_H_TO_L 48
#define RTCC_DIV_2 0
#define RTCC_DIV_4 1
#define RTCC_DIV_8 2
#define RTCC_DIV_16 3
#define RTCC_DIV_32 4
#define RTCC_DIV_64 5
#define RTCC_DIV_128 6
Programação do PIC 16F877 12
#define RTCC_DIV_256 7
#define WDT_18MS 8
#define WDT_36MS 9
#define WDT_72MS 10
#define WDT_144MS 11
#define WDT_288MS 12
#define WDT_576MS 13
#define WDT_1152MS 14
#define WDT_2304MS 15
#define L_TO_H 0x40
#define H_TO_L 0

#define RTCC_ZERO 0x0B20 // Used for ENABLE/DISABLE INTERRUPTS


#define INT_RTCC 0x0B20 // Used for ENABLE/DISABLE INTERRUPTS
#define RB_CHANGE 0x0B08 // Used for ENABLE/DISABLE INTERRUPTS
#define INT_RB 0x0B08 // Used for ENABLE/DISABLE INTERRUPTS
#define EXT_INT 0x0B10 // Used for ENABLE/DISABLE INTERRUPTS
#define INT_EXT 0x0B10 // Used for ENABLE/DISABLE INTERRUPTS

#define GLOBAL 0x0BC0 // Used for ENABLE/DISABLE INTERRUPTS


///////////////////////////////////// Constants used for Timer1 and Timer2
#define T1_DISABLED 0
#define T1_INTERNAL 5
#define T1_EXTERNAL 7
#define T1_EXTERNAL_SYNC 3
#define T1_CLK_OUT 8
#define T1_DIV_BY_1 0
#define T1_DIV_BY_2 0x10
#define T1_DIV_BY_4 0x20
#define T1_DIV_BY_8 0x30
#byte TIMER_1_LOW= 0x0e
#byte TIMER_1_HIGH= 0x0f
#define T2_DISABLED 0
#define T2_DIV_BY_1 4
#define T2_DIV_BY_4 5
#define T2_DIV_BY_16 6
#byte TIMER_2= 0x11

#define INT_TIMER1 0x8C01 // Used for ENABLE/DISABLE INTERRUPTS


#define INT_TIMER2 0x8C02 // Used for ENABLE/DISABLE INTERRUPTS

//////////////////////////////////// Constants used for SETUP_CCP1()


#define CCP_OFF 0
#define CCP_CAPTURE_FE 4
#define CCP_CAPTURE_RE 5
#define CCP_CAPTURE_DIV_4 6
#define CCP_CAPTURE_DIV_16 7
#define CCP_COMPARE_SET_ON_MATCH 8
#define CCP_COMPARE_CLR_ON_MATCH 9
#define CCP_COMPARE_INT 0xA
#define CCP_COMPARE_RESET_TIMER 0xB
#define CCP_PWM 0xC
#define CCP_PWM_PLUS_1 0x1c
#define CCP_PWM_PLUS_2 0x2c
#define CCP_PWM_PLUS_3 0x3c
long CCP_1;
#byte CCP_1 = 0x15
#byte CCP_1_LOW= 0x15
#byte CCP_1_HIGH= 0x16

#define INT_CCP1 0x8C04 // Used for ENABLE/DISABLE INTERRUPTS

//////////////////////////////////// Constants used for SETUP_CCP2()


long CCP_2;
#byte CCP_2 = 0x1B
#byte CCP_2_LOW= 0x1B
#byte CCP_2_HIGH= 0x1C

#define INT_CCP2 0x8D01 // Used for ENABLE/DISABLE INTERRUPTS


Programação do PIC 16F877 13

//////////////////////////////////// Constants used for SETUP_PSP()


#define PSP_ENABLED 0x10
#define PSP_DISABLED 0
#byte PSP_DATA= 8
#define INT_PSP 0x8C80 // Used for ENABLE/DISABLE INTERRUPTS

//////////////////////////////////// Constants used in SETUP_SSP()


#define SPI_MASTER 0x20
#define SPI_SLAVE 0x24
#define SPI_L_TO_H 0
#define SPI_H_TO_L 0x10
#define SPI_CLK_DIV_4 0
#define SPI_CLK_DIV_16 1
#define SPI_CLK_DIV_64 2
#define SPI_CLK_T2 3
#define SPI_SS_DISABLED 1
#define INT_SSP 0x8C08 // Used for ENABLE/DISABLE INTERRUPTS

#define SPI_SAMPLE_AT_END 0x8000


#define SPI_XMIT_L_TO_H 0x4000

#define INT_RDA 0x8C20 // Used for ENABLE/DISABLE INTERRUPTS


#define INT_TBE 0x8C10 // Used for ENABLE/DISABLE INTERRUPTS

///////////////////////////////////// Constants used for SETUP_ADC_PORTS()


#define NO_ANALOGS 0x86 // None
#define ALL_ANALOG 0x80 // RA0 RA1 RA2 RA3 RA5 RE0 RE1 RE2 Ref=Vdd
#define ANALOG_RA3_REF 0x81 // RA0 RA1 RA2 RA5 RE0 RE1 RE2 Ref=RA3
#define A_ANALOG 0x82 // RA0 RA1 RA2 RA3 RA5 Ref=Vdd
#define A_ANALOG_RA3_REF 0x83 // RA0 RA1 RA2 RA5 Ref=RA3
#define RA0_RA1_RA3_ANALOG 0x84 // RA0 RA1 RA3 Ref=Vdd
#define RA0_RA1_ANALOG_RA3_REF 0x85 // RA0 RA1 Ref=RA3

#define ANALOG_RA3_RA2_REF 0x88 // RA0 RA1 RA5 RE0 RE1 RE2 Ref=RA2,RA3
#define ANALOG_NOT_RE1_RE2 0x89 // RA0 RA1 RA2 RA3 RA5 RE0 Ref=Vdd
#define ANALOG_NOT_RE1_RE2_REF_RA3 0x8A // RA0 RA1 RA2 RA5 RE0 Ref=RA3
#define ANALOG_NOT_RE1_RE2_REF_RA3_RA2 0x8B // RA0 RA1 RA5 RE0 Ref=RA2,RA3
#define A_ANALOG_RA3_RA2_REF 0x8C // RA0 RA1 RA5 Ref=RA2,RA3
#define RA0_RA1_ANALOG_RA3_RA2_REF 0x8D // RA0 RA1 Ref=RA2,RA3
#define RA0_ANALOG 0x8E // RA0
#define RA0_ANALOG_RA3_RA2_REF 0x8F // RA0 Ref=RA2,RA3
///////////////////////////////////// Constants used for SETUP_ADC()
#define ADC_OFF 0
#define ADC_CLOCK_DIV_2 1
#define ADC_CLOCK_DIV_8 0x41
#define ADC_CLOCK_DIV_32 0x81
#define ADC_CLOCK_INTERNAL 0xc1

#define ADC_DONE 0x8C40 // Used for ENABLE/DISABLE INTERRUPTS


#define INT_ADC 0x8C40 // Used for ENABLE/DISABLE INTERRUPTS
#define INT_EEPROM 0x0B10 // Used for ENABLE/DISABLE INTERRUPTS

#list

Vous aimerez peut-être aussi