Yo estoy usando el CCS version 4.074.
Aqui esta parte de mi codigo:
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)// RS232 Estándar
#include <241025multi.h>
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
//***********************************************************************************
//* DECLARACION DE INCLUDES *
//***********************************************************************************
#include <string.h>
#include <STDLIB.H>
#include <MATH.H>
#include <Flash_leds.h>
//***********************************************************************************
//* DECLARACION DE REGISTROS *
//***********************************************************************************
#byte reg_TXREG = 0xFAD // Buffer de TX del UART
#byte reg_RCREG = 0xFAE
#byte port_b = 0x0F81 //declaracion del puerto b
//***********************************************************************************
//* DECLARACION DE DEFINES *
//***********************************************************************************
#define ON output_high
#define OFF output_low
#define BUFFER_SIZE 550
int const lenbuff = 32; // Longitud de buffer, Ajustar
//***********************************************************************************
//* DECLARACION DE VARIABLES *
//***********************************************************************************
int xbuff=0x00;
int16 Indice_Buff=0x00;
char Buffer_Modulo1[lenbuff]; // Buffer
char flagcommand = 0;
char Flag_Modulo2 = 0;
char flag = 0;
int UART_Modo;
int16 j;
int p;
int32 q;
int32 r;
int t;
int16 Data_TX;
int Buffer_Cont;
int16 k;
int8 buffer[BUFFER_SIZE];
int16 next_in = 0;
int16 next_out = 0;
int8 n = 0;
int8 Buffer_Modulo2 = 0;
int16 Cont_Data_Modulo2;
int16 Pag_SMS;
int Mensaje_Modulo1 = 0;
int Modulo2_OK;
char Data_Modulo2[538] ;
char Buffer_Pag_Modulo1[9];
int32 Pag_MSB_Modulo1;
char Pagina_Modulo1[4];
int8 bufferx[4];
int Buffer_Pag_Modulo2[2];
int32 Pag_Modulo1;
int32 Pag_Modulo2;
int32 Cont_Pag_Modulo2;
char Ping_ON = 0;
char PAG_ON = 0;
int Conta_Comas;
char Valor[2];
int Nro_Mensajes;
char Variable;
int i;
int Hay_mas_Mensajes;
//***********************************************************************************
//* #priority *
//* Configura la prioridad de las interrupciones del proceso *
//***********************************************************************************
#priority INT_EXT,INT_RDA
//***********************************************************************************
//* #INT_RDA *
//***********************************************************************************
#INT_RDA
void serial_isr() {
unsigned int t, p;
p = getc();
switch (UART_Modo) {
case 1: Add_Buffer_Moudlo1(p);
break;
case 2: Flag_Modulo3 = 1;
buffer[next_in]= p;
t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t;
break;
}
}
//***********************************************************************************
//* INT_RB0 *
//* Monitorea alguna Interrupcion por cambio de estado del RB0 *
//***********************************************************************************
#INT_EXT
void IntRB0()
{
Mensaje_Modulo1 = 1;
}
//***********************************************************************************
//* bkbhit *
//* Llena el buffer del recepcion con los datos del GPS *
//***********************************************************************************
#define bkbhit (next_in!=next_out)
int bgetc() {
BYTE x;
WHILE(!bkbhit) ;
x = buffer[next_out];
next_out=(next_out+1) % BUFFER_SIZE;
return(x);
}
//***********************************************************************************
//* iniBuffer_Modulo1 *
//***********************************************************************************
void Ini_Buffer_Modulo1(void){
int n;
int count=32;
for(n=0;n<count;n++){ // Bucle que pone a 0 todos los
Buffer_Modulo1[n]=0x2; // caracteres en el buffer
}
xbuff=0x00; // Inicializo el índice de siguiente
}
//***********************************************************************************
//* addBuffer_Modulo1 *
//* Llena el buffer de recepcionBuffer_9601 con los caracteres recibidos del *
//* modem 9601 *
//***********************************************************************************
char Add_Buffer_Modulo1(char c){
switch(c){
case 0x0A: // Enter -> Habilita Flag para procesar
if (flag >= 3 )
flagcommand=1;
else
flag++;
break;
default:
Buffer_Modulo1[xbuff++]=c; // Añade carácter recibido al Buffer
}
}
.
.
.
.
.
.
//***********************************************************************************
//* Enable_Int_Hardware *
//* Habilita todas la insterrupciones producidas por el PortB y el RTC *
//***********************************************************************************
void Enable_Int_Hardware(){
enable_interrupts(int_ext); // Activar interrupcion RB0
ext_int_edge(H_TO_L); // por cambio de Alto a Bajo
enable_interrupts(GLOBAL); // Activa todas las Interrupciones
}
//***********************************************************************************
//* Disable_Int_Hardware *
//* Deshabilita todas la insterrupciones producidas por el PortB y el RTC *
//***********************************************************************************
void Disable_Int_Hardware(){
disable_interrupts(int_ext); // Desactivar interrupcion RB0
disable_interrupts(GLOBAL); // Desactiva todas las Interrupciones
}
//***********************************************************************************
//* Enable_Int_UART *
//* Habilita todas la insterrupciones producidas por UART *
//***********************************************************************************
void Enable_Int_UART(){
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
clear_interrupt(INT_RDA);
}
//***********************************************************************************
//* Disable_Int_UART *
//* Deshabilita todas la insterrupciones producidas por UART *
//***********************************************************************************
void Disable_Int_UART(){
disable_interrupts(INT_RDA);
disable_interrupts(GLOBAL);
}
//***********************************************************************************
//* Programa Principal *
//***********************************************************************************
void main(){
SET_TRIS_B (0b11111111);
SET_TRIS_D (0b00000000);
output_bit( PIN_D0, 0);
output_bit( PIN_D1, 0);
Mensaje_Modulo1 =0;
Disable_Int_Hardware();
Disable_Int_UART();
Wr_EEprom_Request();
Init_Modulo1();
enable_Int_Hardware();
Ping_ON = 0;
PAG_ON = 0;
while (TRUE){
if (Mensaje_Modulo1){
disable_Int_Hardware();
Hay_mas_Mensajes = 0;
do{
Interroga_Modulo1();
Mensaje_Modulo1 = 0;
if (Ping_ON ){
Modo_Moudlo1_Ping();
Ping_ON = 0;
}
if (PAG_ON ){
Interroga_Modulo2();
Modo_Modulo3();
PAG_ON = 0;
}
if (Nro_Mensajes != 0){
Nro_Mensajes--;
Hay_mas_Mensajes = 0;
}
else {
Hay_mas_Mensajes = 1;
}
} while (Hay_mas_Mensajes == 0);
enable_Int_Hardware();
}
}
}