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

For favo I need urgent help with EEPROM of the pic18f4620 I

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
oscarec60



Joined: 23 Mar 2006
Posts: 3
Location: Caracas, Venezuela

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

For favo I need urgent help with EEPROM of the pic18f4620 I
PostPosted: Wed Apr 26, 2006 7:41 am     Reply with quote

The proble is the following one, I want that in EEPROM it records me the data that he/she sends me the such keyboard and like it is shown in the code, and then he/she sent them for parallelly for the port TO but for some reason this doesn't make it.

#include <18F4620.h>

#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,WDT128,HS, NOPROTECT, IESO, BROWNOUT, BORV21, NOPUT, NOCPD, NOSTVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, NOFCMEN, NOXINST, NOPBADEN, NOLPT1OSC, NOMCLR
//#define set_tris_d
//#device adc=8
//#use delay(clock=8000000)
//#fuses NOWDT,WDT128,INTRC_IO, NOPROTECT, IESO, BROWNOUT, BORV21, NOPUT, NOCPD, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, NOFCMEN, NOXINST, NOPBADEN, NOLPT1OSC, NOMCLR


#zero_ram

//#define output_d
//#define set_tris_d
#define LCD_DB4 PIN_C4
#define LCD_DB5 PIN_C5
#define LCD_DB6 PIN_C6
#define LCD_DB7 PIN_C7

#define LCD_RS PIN_C0
#define LCD_RW PIN_C1
#define LCD_E PIN_C2
#include <flex_lcd.c>


//-----------------------------------------------------------------------------
// Definiciones globales
//-----------------------------------------------------------------------------

unsigned char edge, bitcount;

char got_interrupt;
char interrupt_count;
char status_b7;

#bit INTF_BIT = 0x0B.1

//-------- Tabla de caracteres correspondientes a la pulsaci�n de la tecla
//-------- en modalidad normal (sin pulsar SHIFT)

unsigned char const unshifted[68][3] = {
0x0d,9,0x00,
0x0e,'�',0x00,
0x15,'q',0x37,
0x16,'1',0x07,
0x1a,'z',0x1d,
0x1b,'s',0x26,
0x1c,'a',0x01,
0x1d,'w',0x3a,
0x1e,'2',0x03,
0x21,'c',0x21,
0x22,'x',0x2d,
0x23,'d',0x31,
0x24,'e',0x11,
0x25,'4',0x31,
0x26,'3',0x21,
0x29,' ',0x00,
0x2a,'v',0x0f,
0x2b,'f',0x23,
0x2c,'t',0x36,
0x2d,'r',0x17,
0x2e,'5',0x11,
0x31,'n',0x35,
0x32,'b',0x03,
0x33,'h',0x13,
0x34,'g',0x33,
0x35,'y',0x3d,
0x36,'6',0x23,
0x39,',',0x02,
0x3a,'m',0x25,
0x3b,'j',0x32,
0x3c,'u',0x0d,
0x3d,'7',0x33,
0x3e,'8',0x13,
0x41,',',0x02,
0x42,'k',0x05,
0x43,'i',0x22,
0x44,'o',0x15,
0x45,'0',0x32,
0x46,'9',0x22,
0x49,'.',0x04,
0x4a,'-',0x0c,
0x4b,'l',0x01,
0x4c,'�',0x3b,
0x4d,'p',0x27,
0x4e,''',0x00,
0x52,'�',0x00,
0x54,'`',0x00,
0x55,'�',0x16,
0x5a,13,0x00,
0x5b,'+',0x00,
0x5d,'�',0x00,
0x61,'<',0x00,
0x66,8,0x00,
0x69,'1',0x01,
0x6b,'4',0x31,
0x6c,'7',0x33,
0x70,'0',0x32,
0x71,'.',0x04,
0x72,'2',0x03,
0x73,'5',0x11,
0x74,'6',0x23,
0x75,'8',0x13,
0x79,'+',0x00,
0x7a,'3',0x21,
0x7b,'-',0x0c,
0x7c,'*',0x00,
0x7d,'9',0x22,
0,0,0
};

//-------- Tabla de caracteres correspondientes a la pulsaci�n de la tecla
//-------- en modalidad desplazamiento (pulsando SHIFT)

unsigned char const shifted[68][3] = {
0x0d,9,0x00,
0x0e,'�',0x00,
0x15,'Q',0x37,
0x16,'!',0x16,
0x1a,'Z',0x1d,
0x1b,'S',0x26,
0x1c,'A',0x01
0x1d,'W',0x3a,
0x1e,'"',0x0e,
0x21,'C',0x21,
0x22,'X',0x2d,
0x23,'D',0x31,
0x24,'E',0x11,
0x25,'$',0x00,
0x26,'�',0x00,
0x29,' ',0x00,
0x2a,'V',0x0f,
0x2b,'F',0x23,
0x2c,'T',0x36,
0x2d,'R',0x17,
0x2e,'%',0x00,
0x31,'N',0x35,
0x32,'B',0x03,
0x33,'H',0x13,
0x34,'G',0x33,
0x35,'Y',0x3d,
0x36,'&',0x00,
0x39,'L',0x07,
0x3a,'M',0x25,
0x3b,'J',0x32,
0x3c,'U',0x0d,
0x3d,'/',0x00,
0x3e,'(',0x1b,
0x41,';',0x06,
0x42,'K',0x05,
0x43,'I',0x22,
0x44,'O',0x15,
0x45,'=',0x00,
0x46,')',0x34,
0x49,':',0x12,
0x4a,'_',0x00,
0x4b,'L',0x07,
0x4c,'�',0x3b,
0x4d,'P',0x27,
0x4e,'?',0x0a,
0x52,'�',0x00,
0x54,'^',0x00,
0x55,'�',0x0a,
0x5a,13,0x00,
0x5b,'*',0x00,
0x5d,'�',0x00,
0x61,'>',0x00,
0x66,8,0x00,
0x69,'1',0x01,
0x6b,'4',0x31,
0x6c,'7',0x33,
0x70,'0',0x32,
0x71,'.',0x04,
0x72,'2',0x03,
0x73,'5',0x11,
0x74,'6',0x23,
0x75,'8',0x13,
0x79,'+',0x00,
0x7a,'3',0x21,
0x7b,'-',0x00,
0x7c,'*',0x00,
0x7d,'9',0x22,
0,0,0
};

//-------- Tabla de caracteres traducido a Braille
//-------- para caracteres cuando ya ha sido pulsado el SHIFT y le corresponde primero el caracter de mayuscula en Braille




//-----------------------------------------------------------------------------
// Definici�n de protipos
//-----------------------------------------------------------------------------

void init_kb(void);
void decode(unsigned char sc);


#int_ext
void int_ext_isr(void);

//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------

int j;

void main(void)
{
j=0;
//setup_adc_ports(AN0|VSS_VDD);
//setup_adc(ADC_CLOCK_INTERNAL);

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);

// setup_psp(PSP_ENABLED);
setup_psp(PSP_DISABLED);




setup_spi(FALSE);
setup_wdt(WDT_OFF);

// set_adc_channel( 0 ); //RA0 como entrada
// delay_us(100);

setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);

setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);

lcd_init();
init_kb();
//lcd_gotoxy(0x00,0x00);
//printf(lcd_putc," \n ");
//lcd_gotoxy(0x00,0x00);


//-------- Los pins indicados (B0 y B7) son configurados como entradas.
output_float(PIN_B0);
output_float(PIN_B7);

//-------- Activa pullups sobre todos los pins del puerto B.
port_b_pullups(TRUE);

//-------- Espera a que se activen.
delay_us(5);

//-------- Inicializa las variables usadas por la rutina de interrupci�n
//-------- antes de activar las interrupciones
interrupt_count = 0;
got_interrupt = FALSE;
status_b7 = 0;

//-------- Desde que se activ� el modo PULLUPS del puerto B, el estado
//-------- normal del pin B0 es ALTO. La gesti�n de la interrupci�n externa
//-------- se gestiona cuando se produce un cambio de nivel ALTO a BAJO.
ext_int_edge(H_TO_L);

//-------- Asegurarse de que el el bit de flag de la interrupci�n externa
//-------- es borrado antes de activar la gesti�n de dicha interrupci�n
//-------- externa.
INTF_BIT = 0;

enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);

//-------- Bucle principal.
//-------- Chequear si se produce alguna interrupci�n (got_interrupt). Si es as�, contar, borrar
//-------- el flag y esperar 50 ms, reactivando la gesti�n de las interrupciones
while(1)

{

//-------- Chequear si se produce alguna interrupci�n (got_interrupt).
if(got_interrupt == TRUE)

{

//-------- Borrar el flag global que se inicio en la rutina de servicio
//-------- de interrupciones externas.
got_interrupt = FALSE;

//-------- Esperar 50 ms para evitar rebotes en los contactos de las teclas.
//delay_ms(50);

//-------- Borrar cualquier interrupci�n producida durante el periodo de espera.
INTF_BIT = 0;

//-------- Reactivar interrupciones
enable_interrupts(INT_EXT);

} // --- End If ---

} // --- End While ---

} // --- End MAIN ---


//-----------------------------------------------------------------------------
// Funciones
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// Inicializaci�n de teclado.
//-----------------------------------------------------------------------------
void init_kb(void)
{

//-------- Longitud de la trama para cada pulsaci�n y mensaje de bienvenida
bitcount = 11;
printf(lcd_putc,"Dispositivo para\n Sordo-Ciegos ");
delay_ms(1000);

}


//-----------------------------------------------------------------------------
// Decodificaci�n de pulsaciones
//-----------------------------------------------------------------------------
void decode(unsigned char sc)
{
static unsigned char is_up=0, shift = 0, mode = 0;
unsigned char i;

unsigned char x=0;


//-------- El �ltimo dato recibido fue el identificador de Up-Key
if (!is_up)
{
switch (sc)
{
//-------- Identificador de Up-Key
case 0xF0 :
is_up = 1;
break;
//-------- SHIFT Izquierdo
case 0x12 :
shift = 1;
break;
//-------- SHIFT Derecho
case 0x59 :
shift = 1;
break;
//-------- ENTER
case 0x5A :
shift = 0;
for(i=0; i == j ;i++)
{
output_a(read_eeprom(i));
delay_ms(1000);
output_a(0x00);
i++;
}
if(j<16 && x == 0)
{
printf(lcd_putc,"\n");
j=0;
x=1;
}
else
{
//printf(lcd_putc," \n ");
// lcd_gotoxy(0x00,0x00);
j=0;
x=0;
}
break;
//-------- Si no es ninguno de los identificadores especiales, procesar
//-------- pulsaci�n, localizando caracter en tabla de caracteres.
default:
//-------- Pulsaci�n normal
if(!shift)
{
for(i = 0; unshifted[i][0]!=sc && unshifted[i][0]; i++);
printf(lcd_putc,"%c", unshifted[i][1]);
if(sc == 0x66)
{
j--;
}
else
{

write_eeprom(j,unshifted[i][2]);
j++;
}
}
else
//-------- Pulsaci�n + SHIFT presionado
{
for(i = 0; shifted[i][0]!=sc && shifted[i][0]; i++);

if (shifted[i][0] == sc)
{
printf(lcd_putc,"%c", shifted[i][1]);
write_eeprom(j,0x28);
j++;
write_eeprom(j,0x00);
j++;
write_eeprom(j,shifted[i][2]);
j++;
}

}
break;
} // --- End Switch
}
else
{
//-------- No se permiten 2 0xF0 en una fila
is_up = 0;
switch (sc)
{
//-------- SHIFT Izquierdo
case 0x12 :
shift = 0;
break;
//-------- SHIFT Derecho
case 0x59 :
shift = 0;
break;
} // --- End Switch
}
}



//-----------------------------------------------------------------------------
// Rutina de gesti�n de interrupciones
//-----------------------------------------------------------------------------

#int_ext
void int_ext_isr(void)
{

unsigned char data;

//-------- Los bit 3 a 10 se considerran datos. Paridad, start y stop
//-------- son ignorados
if(bitcount < 11 && bitcount > 2)
{
data = (data >> 1);
status_b7 = input(PIN_B7);
if((status_b7) == 1)
data = data | 0x80;
}

//-------- Todos los bits se han recibido
if(--bitcount == 0)
{
decode(data);
data = 0;
bitcount = 11;
got_interrupt = TRUE;

}

got_interrupt = TRUE;
interrupt_count++;

disable_interrupts(INT_EXT);
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Apr 26, 2006 8:42 am     Reply with quote

When posting code please use the 'code' buttons at the start and end of your code section, this will help to keep the formatting of your code intact.

I only had a very quick look at your code, the next line jumped out as an obvious error.
Code:
 for(i=0; i == j ;i++)


Maybe there are more errors in your program but I don't have time to look into it now.
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