TODOPIC
Microcontroladores PIC => Lenguaje C para microcontroladores PIC => Mensaje iniciado por: nahueldiaz1992 en 27 de Febrero de 2014, 22:14:34
-
hola gente tome este codigo ya que hace no mas de una semana solo programaba en asm pero como resulta que los codigos en c son mas compactos decidi hacer mi proyecto en c pero hay un error que me tira el compilador en CCS y no se a que se refiere o como arreglarlo si me ayudan pliss :?
#include <16F88.h>
#fuses XT //Oscilador a cristal standar
#fuses NOWDT //sin WatchDog Timer
#fuses NOPROTECT //sin proteccion de memoria de programa
#fuses NOPUT //sin PowerUp Timer
#fuses NOBROWNOUT //sin brownout
#fuses NOLVP //sin programación en baja tensión
#use delay(clock=4000000)
#include "lib_rf2gh4_10.h" // Librería para manejar el módulo SPI con el nRF24L01.
#byte porta=0x05 // Dirección del puerto A.
#byte portb=0x06 // Dirección del puerto B.
int8 ret1;
int8 data;
void main() //Programa principal
{
set_tris_a(0b100101); // RA0 sustituye a RB0 y se pone un LED en RA0.
set_tris_b(0b11000010); // RB0 es para la interrupción, el resto son LEDs.
RF_CONFIG_SPI(); // Configurar módulos SPI del PIC.
RF_CONFIG(0x40,0x08); // Configurar módulo RF (canal y dirección).
RF_ON(); // Activar el módulo RF.
}
while(1)
{
ret1 = RF_RECEIVE();
if ( (ret1 == 0) || (ret1 == 1) )
{
do
{
data=RF_DATA[0]; // Data contendrá el valor que le llege del emisor, a través de RF_DATA[0].
ret1 = RF_RECEIVE();
#asm
btfss data,0
bcf PORTA,4
BTFSC data,0
BSF PORTA,4
btfss data,1
bcf PORTB,0
BTFSC data,1
BSF PORTB,0
btfss data,2
bcf PORTB,3
BTFSC data,2
BSF PORTB,3
#endasm
} while ( (ret1 == 0) || (ret1 == 1) ); // Tanto si existe entrada múltiple o simple de datos los lee.
}
}
libreria=
// PORTB
#define RF_IRQ PIN_A2
#define RF_IRQ_TRIS TRISA,2
// PORTC
#define RF_CS PIN_B5
#define RF_CE PIN_A3
#define SCK PIN_B4
#define SDI PIN_B1
#define SDO PIN_B2
#define RF_CS_TRIS TRISB,5
#define RF_CE_TRIS TRISA,3
#define SCK_TRIS TRISB,4
#define SDI_TRIS TRISB,1
#define SDO_TRIS TRISB,2
//*****************
//* VARIABLES *
//*****************
#BYTE TRISA = 0x85
#BYTE TRISB = 0x86
#BYTE INTCON = 0x10B // Registro de interrupciones. Sólo es importante el bit 7, GIE=interrupciones globales.
//Variables internas
static int1 interRF;
static int16 noRF;
static int1 RCVNW=0;
static int8 DATA_N_SND=0;
static int8 DATA_N_RCV=0;
//Variables configurables
static int8 RF_DATA[8];
static int8 RF_DIR;
//**************
//* CÓDIGO *
//**************
//*****************************************************
//* RF_CONFIG_SPI() *
//*****************************************************
//*Descripción: La función configura el módulo SPI del*
//*microcontrolador.En ella se especifica como salida *
//*SDO y como entrada SDI entre otros parámetros del *
//*protocolo SPI. *
//*****************************************************
//*Variables de entrada: *
//*Variables de salida: *
//*****************************************************
void RF_CONFIG_SPI()
{
//Configuración I/O.
bit_clear(SCK_TRIS);
bit_set(SDI_TRIS);
bit_clear(SDO_TRIS);
//Configuración módulo comunicaciones.
setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_XMIT_L_TO_H|SPI_CLK_DIV_4|SPI_SAMPLE_AT_END);
}
//*****************************************************
//*****************************************************
//* RF_INT_EN() *
//*****************************************************
//*Descripción:Se encarga de habilitar la interrupción*
//*externa (RB0) utilizada por el módulo de RF en la *
//*recepción de datos. *
//*****************************************************
//*Variables de entrada: *
//*Variables de salida: *
//*****************************************************
void RF_INT_EN()
{
//Habilitar interrupciones externas con flanco de
//bajada.
disable_interrupts(global);
enable_interrupts(int_ext);
ext_int_edge( H_TO_L );
bit_set(RF_IRQ_TRIS);
enable_interrupts(global);
}
//*****************************************************
//*****************************************************
//* RF_CONFIG(int canal, int dir) *
//*****************************************************
//*Descripción:Esta función se encarga de configurar *
//*el transceptor habilitando su propia dirección de *
//*escucha y el canal entre otros parámetros. *
//*****************************************************
//*Variables de entrada:- Canal *
//* - Direccion *
//*Variables de salida: *
//*****************************************************
void RF_CONFIG(int canal, int dir)
{
bit_clear(RF_CS_TRIS);
bit_set(RF_IRQ_TRIS);
bit_clear(RF_CE_TRIS);
output_low(RF_CE);
// TX_ADDR (0xFF)
//Configuración de la dirección de envío aleatoria.
//En la función de enviar se configura la dirección
//deseada por el usuario.
output_low(RF_CS);
spi_write(0x30);
spi_write(0xFF);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
output_high(RF_CS);
// RX_ADDR_P0 (0xFF) ACK
//Configuración de la direccióndel Pipe0 para la
//recepción de ACK.
output_low(RF_CS);
spi_write(0x2A);
spi_write(0xFF);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
output_high(RF_CS);
// RX_ADDR_P1 (dir)
//Configuración de la direccióndel Pipe1 para la
//recepción de tramas.
output_low(RF_CS);
spi_write(0x2B);
spi_write(dir);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
output_high(RF_CS);
// RX_ADDR_P2 (0x00) BROADCAST
//Configuración de la direccióndel Pipe2 para la
//recepción de tramas
output_low(RF_CS);
spi_write(0x2C);
spi_write(0x00);
output_high(RF_CS);
// EN_AA
//Habilitar AutoAck en los Pipe0,Pipe1 y Pipe2.
output_low(RF_CS);
spi_write(0x21);
spi_write(0x07);
output_high(RF_CS);
// EN_RXADDR
//Habilitar los Pipe0,Pipe1 y Pipe2.
output_low(RF_CS);
spi_write(0x22);
spi_write(0x07);
output_high(RF_CS);
// SETUP_AW
//Configuración de la longitud de las direcciones.
//Direcciones de 5 bytes.
output_low(RF_CS);
spi_write(0x23);
spi_write(0x03);
output_high(RF_CS);
//SETUP_RETR
//Configuración de las retrasmisiones en la transmisión.
//Diez retransmisiones cada 336us.
output_low(RF_CS);
spi_write(0x24);
spi_write(0x0A);
output_high(RF_CS);
//RF_CH
//Configuración del canal.
//Canal elegido por el usuario (0x01 - 0x7F).
output_low(RF_CS);
spi_write(0x25);
spi_write(canal);
output_high(RF_CS);
//RF_SETUP
//Configuración aspectos RF. *******************************************************************************************
//Ganancia máxima de LNA, 0dBm potencia de salida y 2Mbps de velocidad. ************************************************
output_low(RF_CS);
spi_write(0x26);
spi_write(0x07); // Lo he cambiado a 1Mbps. Originalmente era 0x0F.
output_high(RF_CS);
//STATUS
//Reseteo del registro STATUS
output_low(RF_CS);
spi_write(0x27);
spi_write(0x70);
output_high(RF_CS);
//RX_PW_P0
//Nº de bytes en Pipe0.
//1 byte (ACK).
output_low(RF_CS);
spi_write(0x31);
spi_write(0x01);
output_high(RF_CS);
//RX_PW_P1
//Nº de bytes en Pipe1.
//10 byte (Direccion emisor y trama).
output_low(RF_CS);
spi_write(0x32);
spi_write(0x0A);
output_high(RF_CS);
//RX_PW_P2
//Nº de bytes en Pipe2.
//10 byte (Direccion emisor y trama).
output_low(RF_CS);
spi_write(0x33);
spi_write(0x0A);
output_high(RF_CS);
}
//*****************************************************
//*****************************************************
//* RF_ON() *
//*****************************************************
//*Descripción:Esta rutina activa el módulo de *
//*radiofrecuencia en modo escucha para poder recibir *
//*datos enviados a su dirección. *
//*****************************************************
//*Variables de entrada: *
//*Variables de salida: *
//*****************************************************
void RF_ON()
{
output_low(RF_CE);
// CONFIG
//Se activa el modulo, se pone en recepción,
//se activa el CRC para que utilice 2 bytes.
output_low(RF_CS);
spi_write(0x20);
spi_write(0x0F);
output_high(RF_CS);
delay_ms(2);
output_high(RF_CE);
delay_us(150);
}
//*****************************************************
//*****************************************************
//* RF_OFF() *
//*****************************************************
//*Descripción:Este procedimiento desactiva el módulo *
//*de radiofrecuencia. *
//*****************************************************
//*Variables de entrada: *
//*Variables de salida: *
//*****************************************************
void RF_OFF()
{
output_low(RF_CE);
// CONFIG
//Se desactiva el modulo
output_low(RF_CS);
spi_write(0x20);
spi_write(0x0C);
output_high(RF_CS);
}
//*****************************************************
//*****************************************************
//* RF_SEND() *
//*****************************************************
//*Descripción:Esta función envía 8 Bytes de datos a *
//*la dirección indicada informando de la correcta *
//*recepción en el destinatario. *
//*****************************************************
//*Variables de entrada:- RF_DATA[] *
//* - RF_DIR
//*Variables de salida: - *
//*Salida: - 0: Envío correcto (ACK OK) *
//* - 1: No recepcibido (NO ACK) *
//* - 2: No enviado *
//*****************************************************
int RF_SEND()
{
int i;
int estado;
if(bit_test(INTCON,7))
interRF=1;
else
interRF=0;
disable_interrupts(GLOBAL);
// INICIO
output_low(RF_CE);
//STATUS
//Reseteo del registro STATUS
output_low(RF_CS);
spi_write(0x27);
spi_write(0x70);
output_high(RF_CS);
// EN_RXADDR
//Se habilita el Pipe0 para la recepción del ACK
output_low(RF_CS);
spi_write(0x22);
spi_write(0x01);
output_high(RF_CS);
// TX_ADDR
//Se configura la dirección de transmisión=RF_DIR
output_low(RF_CS);
spi_write(0x30);
spi_write(RF_DIR);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
output_high(RF_CS);
// RX_ADDR_P0
//Para la recepción del ACK se debe configurar el Pipe0 con
//la misma dirección a trasmitir.
output_low(RF_CS);
spi_write(0x2A);
spi_write(RF_DIR);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
spi_write(0xC2);
output_high(RF_CS);
// RX_ADDR_P1
//Se mete en RF_DIR la direccion propia.
//De esta manera el receptor sabe la dirección
//del transmisor.
output_low(RF_CS);
spi_write(0x0B);
RF_DIR=spi_read(0);
spi_read(0);
spi_read(0);
spi_read(0);
spi_read(0);
output_high(RF_CS);
// W_TX_PAYLOAD
//Se manda los datos al transductor
output_low(RF_CS);
spi_write(0xA0);
DATA_N_SND++;
spi_write(DATA_N_SND);
spi_write(RF_DIR);
for (i=0;i<8;i++)
{
spi_write(RF_DATA);
}
output_high(RF_CS);
// CONFIG
//Se pasa a modo transmisión.
output_low(RF_CS);
spi_write(0x20);
spi_write(0x0E);
output_high(RF_CS);
// Pulso de comienzo de envío
output_high(RF_CE);
delay_us(15);
output_low(RF_CE);
noRF=0;
while (input(RF_IRQ)==1) {
noRF++;
//Si no da respuesta en 7ms, no se ha enviado.
if(noRF==500) { break; }
}
// STATUS
//Lectura del estado en el registro estatus.
output_low(RF_CS);
estado=spi_read(0x27);
spi_write(0x70);
output_high(RF_CS);
// EN_RXADDR
//Habilitar los Pipe0,Pipe1 y Pipe2.
output_low(RF_CS);
spi_write(0x22);
spi_write(0x07);
output_high(RF_CS);
// TX_FLUSH
//Limpieza de la FIFO de salida
output_low(RF_CS);
spi_write(0xE1);
output_high(RF_CS);
// CONFIG
//Paso a modo recepción
output_low(RF_CS);
spi_write(0x20);
spi_write(0x0F);
output_high(RF_CS);
// FIN
output_high(RF_CE);
delay_us(150);
//Si no da respuesta en 7ms, no se ha enviado.
if(noRF==500)
{
if(interRF==1)
enable_interrupts(GLOBAL);
clear_interrupt(int_ext);
return(2);
}
//estado
//Chequeo de los bit del registro STATUS que indican si se ha recibido
//ACK y si se ha terminado las retrasmisiones sin ningun ACK.
if ((bit_test(estado,4)==0) && (bit_test(estado,5)==1)){
if(interRF==1)
enable_interrupts(GLOBAL);
clear_interrupt(int_ext);
return(0);
}
else{
if(interRF==1)
enable_interrupts(GLOBAL);
clear_interrupt(int_ext);
return(1);
}
}
//*****************************************************
//*****************************************************
//* RF_RECEIVE() *
//*****************************************************
//*Descripción: Esta rutina se encarga de comprobar si*
//*se ha producido una recepción y de ser así, *
//*devuelve la trama recibida. *
//*****************************************************
//*Variables de entrada:- *
//*Variables de salida: - RF_DATA[] *
//* - RF_DIR *
//*Salida: - 0: Recepción correcta y única *
//* - 1: Recepción correcta y múltiple *
//* - 2: No se ha producido recepción *
//* - 3: No se ha producido recepción *
//*****************************************************
int RF_RECEIVE()
{
int i;
int mas;
int estado;
if (input(RF_IRQ)==1 && RCVNW==0){
return (2);
}
//STATUS
//Lectura y reseteo del registro STATUS
output_low(RF_CS);
estado=spi_read(0x27);
spi_write(0x70);
output_high(RF_CS);
//estado
//Chequeo de la interrupción de recepción.
if (bit_test(estado,6)==0 && RCVNW==0){
return(3);
}
//R_RX_PAYLOAD
//Lectura de los datos recibidos.
output_low(RF_CS);
spi_write(0x61);
DATA_N_RCV=spi_read(0);
RF_DIR=spi_read(0);
for (i=0;i<8;i++)
{
RF_DATA=spi_read(0);
}
output_high(RF_CS);
//FIFO_STATUS
//Comprobación del estado de la FIFO de
//recepción para comprobar si hay más datos
output_low(RF_CS);
spi_write(0x17);
mas=spi_read(0);
output_high(RF_CS);
if (bit_test(mas,0)==0){
RCVNW=1;
return(1);
}
RCVNW=0;
return(0);
}
//*****************************************************
//////// Standard Header file for the PIC16F88 device ////////////////
#device PIC16F88
#nolist
//////// Program memory: 4096x14 Data RAM: 367 Stack: 8
//////// I/O: 16 Analog Pins: 7
//////// Data EEPROM: 256
//////// C Scratch area: 77 ID Location: 2000
//////// Fuses: LP,XT,HS,EC_IO,NOWDT,WDT,NOPUT,PUT,MCLR,NOMCLR,BROWNOUT
//////// Fuses: NOBROWNOUT,LVP,NOLVP,CPD,NOCPD,WRT,NOWRT,DEBUG,NODEBUG,CCPB0
//////// Fuses: CCPB3,PROTECT,NOPROTECT,INTRC,INTRC_IO,RC,RC_IO,FCMEN
//////// Fuses: NOFCMEN,IESO,NOIESO
////////
////////////////////////////////////////////////////////////////// I/O
// Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
// PORT_x_PULLUPS(), INPUT(),
// OUTPUT_LOW(), OUTPUT_HIGH(),
// OUTPUT_FLOAT(), OUTPUT_BIT()
// Constants used to identify pins in the above are:
#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_A6 46
#define PIN_A7 47
#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
////////////////////////////////////////////////////////////////// Useful defines
#define FALSE 0
#define TRUE 1
#define BYTE int
#define BOOLEAN short int
#define getc getch
#define fgetc getch
#define getchar getch
#define putc putchar
#define fputc putchar
#define fgets gets
#define fputs puts
////////////////////////////////////////////////////////////////// Control
// Control Functions: RESET_CPU(), SLEEP(), RESTART_CAUSE()
// Constants returned from RESTART_CAUSE() are:
#define WDT_FROM_SLEEP 3
#define WDT_TIMEOUT 11
#define MCLR_FROM_SLEEP 19
#define MCLR_FROM_RUN 27
#define NORMAL_POWER_UP 24
#define BROWNOUT_RESTART 26
////////////////////////////////////////////////////////////////// Timer 0
// Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER_0(),
// SET_TIMER0() or SET_RTCC(),
// GET_TIMER0() or GET_RTCC()
// Constants used for SETUP_TIMER_0() are:
#define RTCC_INTERNAL 0
#define RTCC_EXT_L_TO_H 32
#define RTCC_EXT_H_TO_L 48
#define RTCC_DIV_1 8
#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
#define RTCC_DIV_256 7
#define RTCC_8_BIT 0
// Constants used for SETUP_COUNTERS() are the above
// constants for the 1st param and the following for
// the 2nd param:
////////////////////////////////////////////////////////////////// WDT
// Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
// RESTART_WDT()
//
#define WDT_18MS 0x8000
#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
// One of the following may be OR'ed in with the above:
#define WDT_ON 0x8100
#define WDT_OFF 0
#define WDT_DIV_16 0x100
#define WDT_DIV_8 0x300
#define WDT_DIV_4 0x500
#define WDT_DIV_2 0x700
#define WDT_TIMES_1 0x900 // Default
#define WDT_TIMES_2 0xB00
#define WDT_TIMES_4 0xD00
#define WDT_TIMES_8 0xF00
#define WDT_TIMES_16 0x1100
#define WDT_TIMES_32 0x1300
#define WDT_TIMES_64 0x1500
#define WDT_TIMES_128 0x1700
////////////////////////////////////////////////////////////////// Timer 1
// Timer 1 Functions: SETUP_TIMER_1, GET_TIMER1, SET_TIMER1
// Constants used for SETUP_TIMER_1() are:
// (or (via |) together constants from each group)
#define T1_DISABLED 0
#define T1_INTERNAL 0x85
#define T1_EXTERNAL 0x87
#define T1_EXTERNAL_SYNC 0x83
#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
////////////////////////////////////////////////////////////////// Timer 2
// Timer 2 Functions: SETUP_TIMER_2, GET_TIMER2, SET_TIMER2
// Constants used for SETUP_TIMER_2() are:
#define T2_DISABLED 0
#define T2_DIV_BY_1 4
#define T2_DIV_BY_4 5
#define T2_DIV_BY_16 6
////////////////////////////////////////////////////////////////// CCP
// CCP Functions: SETUP_CCPx, SET_PWMx_DUTY
// CCP Variables: CCP_x, CCP_x_LOW, CCP_x_HIGH
// Constants used for SETUP_CCPx() are:
#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
////////////////////////////////////////////////////////////////// SPI
// SPI Functions: SETUP_SPI, SPI_WRITE, SPI_READ, SPI_DATA_IN
// Constants used in SETUP_SPI() are:
#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 SPI_SAMPLE_AT_END 0x8000
#define SPI_XMIT_L_TO_H 0x4000
////////////////////////////////////////////////////////////////// UART
// Constants used in setup_uart() are:
// FALSE - Turn UART off
// TRUE - Turn UART on
#define UART_ADDRESS 2
#define UART_DATA 4
////////////////////////////////////////////////////////////////// COMP
// Comparator Variables: C1OUT, C2OUT
// Constants used in setup_comparator() are:
#define NC_NC_NC_NC 0x0ff07
#define A0_A3_A1_A2 0xfff04
#define A0_A2_A1_A2 0x7ff03
#define A0_VR_A1_VR 0x3ff02
#define A3_VR_A2_VR 0xcff0a
#define A3_A2_A1_A2 0xeff0b
#define NC_NC_A1_A2 0x6ff05
#define A0_A2_A1_A2_OUT_ON_A3_A4 0x7e706
#bit C1OUT = 0x9c.6
#bit C2OUT = 0x9c.7
////////////////////////////////////////////////////////////////// VREF
// Constants used in setup_vref() are:
//
#define VREF_LOW 0xa0
#define VREF_HIGH 0x80
// Or (with |) the above with a number 0-15
#define VREF_A2 0x40
////////////////////////////////////////////////////////////////// INTERNAL RC
// Constants used in setup_oscillator() are:
#define OSC_31KHZ 0
#define OSC_125KHZ 0x10
#define OSC_250KHZ 0x20
#define OSC_500KHZ 0x30
#define OSC_1MHZ 0x40
#define OSC_2MHZ 0x50
#define OSC_4MHZ 0x60
#define OSC_8MHZ 0x70
// The following may be OR'ed in with the above using |
#define OSC_TIMER1 1
#define OSC_INTRC 2
#define OSC_NORMAL 0
// A second optional parameter may be used with this part to fine
// tune the speed (signed int,0-63)
// Result may be (ignore all other bits)
#define OSC_STATE_STABLE 4
#define OSC_STATE_EXT_RUNNING 8
////////////////////////////////////////////////////////////////// ADC
// ADC Functions: SETUP_ADC(), SETUP_ADC_PORTS() (aka SETUP_PORT_A),
// SET_ADC_CHANNEL(), READ_ADC()
// Constants used for SETUP_ADC() are:
#define ADC_OFF 0 // ADC Off
#define ADC_CLOCK_DIV_2 0x10000
#define ADC_CLOCK_DIV_4 0x4000
#define ADC_CLOCK_DIV_8 0x0040
#define ADC_CLOCK_DIV_16 0x4040
#define ADC_CLOCK_DIV_32 0x0080
#define ADC_CLOCK_DIV_64 0x4080
#define ADC_CLOCK_INTERNAL 0x00c0 // Internal 2-6us
// Constants used in SETUP_ADC_PORTS() are:
#define sAN0 1 //| A0
#define sAN1 2 //| A1
#define sAN2 4 //| A2
#define sAN3 8 //| A3
#define sAN4 16 //| A4
#define sAN5 32 //| B6
#define sAN6 64 //| B7
#define NO_ANALOGS 0 // None
#define ALL_ANALOG 127 // A0 A1 A2 A3 A4 B6 B7
// The following may be OR'ed in with the above using |
#define VSS_VDD 0x0000 // Range 0-Vdd
#define VREF_VDD 0x1000 // Range VrefL-Vdd
#define VSS_VREF 0x2000 // Range 0-VrefH
#define VREF_VREF 0x3000 // Range VrefL-VrefH
// Constants used in READ_ADC() are:
#define ADC_START_AND_READ 7 // This is the default if nothing is specified
#define ADC_START_ONLY 1
#define ADC_READ_ONLY 6
////////////////////////////////////////////////////////////////// INT
// Interrupt Functions: ENABLE_INTERRUPTS(), DISABLE_INTERRUPTS(),
// EXT_INT_EDGE()
//
// Constants used in EXT_INT_EDGE() are:
#define L_TO_H 0x40
#define H_TO_L 0
// Constants used in ENABLE/DISABLE_INTERRUPTS() are:
#define GLOBAL 0x0BC0
#define INT_RTCC 0x0B20
#define INT_RB 0xFF0B08
#define INT_EXT 0x0B10
#define INT_AD 0x8C40
#define INT_TBE 0x8C10
#define INT_RDA 0x8C20
#define INT_TIMER1 0x8C01
#define INT_TIMER2 0x8C02
#define INT_CCP1 0x8C04
#define INT_SSP 0x8C08
#define INT_EEPROM 0x8D10
#define INT_TIMER0 0x0B20
#define INT_COMP 0x8D40
#define INT_OSC_FAIL 0x8D80
#list
desde ya gracias por cualquier ayuda !
-
y cuál es el error que te muestra?
-
y cuál es el error que te muestra?
Perdon pense que lo habia puesto al error , me dice expecting an identifier en la linea donde empieza el codigo en assembler:
-
Creo que debe ser por la versión usada al compilar.
Creo que debes poner el sufijo _ antes de cada nombre de variable en assembler.
Deberias probar escribiendolo asi:
#asm
btss data,0
bcf PORTA,4
BTSC data,0
BSF PORTA,4
btss data,1
bcf PORTB,0
BTSC data,1
BSF PORTB,0
btss data,2
bcf PORTB,3
BTSC data,2
BSF PORTB,3
#endasm
Ya que según el manual (https://www.ccsinfo.com/downloads/ccs_c_manual.pdf) las otras instrucciones no están... :shock: :shock:
BTG Wd,B Wa.bit = ~Wa.bit
BTG f,B f.bit = ~f.bit
BTG.B Wd,B Wa.bit = ~Wa.bit (byte)
BTSC f,B Skip if f.bit = 0
BTSC Wd,B Skip if Wa.bit4 = 0
BTSS f,B Skip if f.bit = 1
BTSS Wd,B Skip if Wa.bit = 1
BTST f,B Z = f.bit
BTST.C Wa,Wd C = Wa.Wb
BTST.C Wd,B C = Wa.bit
BTST.Z Wd,B Z = Wa.bit
BTST.Z Wa,Wd Z = Wa.Wb
BTSTS f,B Z = f.bit; f.bit = 1
BTSTS.C Wd,B C = Wa.bit; Wa.bit = 1
BTSTS.Z Wd,B Z = Wa.bit; Wa.bit = 1
-
Creo que debe ser por la versión usada al compilar.
Creo que debes poner el sufijo _ antes de cada nombre de variable en assembler.
Deberias probar escribiendolo asi:
#asm
btss data,0
bcf PORTA,4
BTSC data,0
BSF PORTA,4
btss data,1
bcf PORTB,0
BTSC data,1
BSF PORTB,0
btss data,2
bcf PORTB,3
BTSC data,2
BSF PORTB,3
#endasm
Ya que según el manual (https://www.ccsinfo.com/downloads/ccs_c_manual.pdf) las otras instrucciones no están... :shock: :shock:
BTG Wd,B Wa.bit = ~Wa.bit
BTG f,B f.bit = ~f.bit
BTG.B Wd,B Wa.bit = ~Wa.bit (byte)
BTSC f,B Skip if f.bit = 0
BTSC Wd,B Skip if Wa.bit4 = 0
BTSS f,B Skip if f.bit = 1
BTSS Wd,B Skip if Wa.bit = 1
BTST f,B Z = f.bit
BTST.C Wa,Wd C = Wa.Wb
BTST.C Wd,B C = Wa.bit
BTST.Z Wd,B Z = Wa.bit
BTST.Z Wa,Wd Z = Wa.Wb
BTSTS f,B Z = f.bit; f.bit = 1
BTSTS.C Wd,B C = Wa.bit; Wa.bit = 1
BTSTS.Z Wd,B Z = Wa.bit; Wa.bit = 1
Gracias por la ayuda igual hoy mas temprano me comentaron en un foro que era porque la variable data estaba reservada por el compilador u el micro y lo unico que tenia que hacer era cambiar el nombre de la variable y funciono :P
igualmente gracias
-
Me alegro!!
Igual me quede con la espina y compile un programa de ejemplo y funciona, creo que la ayuda tiene algun bug !! :D :D