I am developing a small aplication that will read a code from a barcode reader.
I tested it with a pic 16f877 and it worked fine.
Now, I want to make it work with a pic 16f88 because of physical space but I am experimenting a problem when I try to compile the code.
The error returned by the compiler is :
Undeclared identifier [EEprom_Read] in expression
and
Undeclared identifier [EEprom_Write] in expression
As I said before, the code compiles and runs fine in a 16f877 (I just modified the ports I use).
The code is :
Code: Select all
/*****************************************************************************
* Name : Ps2_c_P16_Example.c *
* Rev : 1.0 *
* *
* Modified by : Sergio A.S. de Aguiar *
* Date : 07/11/2005 *
******************************************************************************
******************************************************************************
**** PIC 16f88 Pinout : ****
**** ****
**** +--()---+ ****
**** RA2/AN2 | 1 18 | RA1/AN1 ****
**** RA3/AN3 | 2 17 | RA0/AN0 ****
**** RA4/AN4 | 3 16 | RA7/OSC1 ****
**** RA5/MCLR* | 4 15 | RA6/OSC2 ****
**** VSS (gnd) | 5 14 | VDD ****
**** RB0/INT | 6 13 | RB7/AN6 ****
**** RB1/SDI/SDA | 7 12 | RB6/AN5 ****
**** RB2/SDO/RX/DT | 8 11 | RB5/TX/CK ****
**** RB3/PGM/CCP1 | 9 10 | RB4/SCK/SCL ****
**** +-------+ ****
******************************************************************************/
/*****************************************************************************/
// Variables definition :
//
unsigned short
keydata = 0, special = 0, down = 0, BuffPtr = 0, i = 0;
char
data[20], old_data[20];
/*****************************************************************************/
// Constants definition :
//
#define BUZZER PORTA.F4
/*****************************************************************************/
// Prototypes :
//
void sound (unsigned short ntimes);
/*****************************************************************************/
// Main routine:
//
void main() {
CMCON = 0x07; // Disable analog comparators (877A)
INTCON = 0; // Disable all interrupts
PORTB = 0; // Zero PORTB
TRISB = 0; // PORTB all out
memset (data, 0, 20); // Clear buffers
memset (old_data, 0, 20); // " "
Ps2_Init(&PORTA); // Init PS/2 Keyboard on PORTC
Delay_ms(100); // Wait for keyboard to finish
Lcd_Init(&PORTB); // Init Lcd Interface
Lcd_Cmd(LCD_CURSOR_OFF); // Lcd cursor off
Lcd_Cmd(LCD_CLEAR); // Clear Lcd
for (i = 0; i < 20u; i++) // Read stored code from EEprom
old_data[i] = EEprom_Read(i);
do
{
if (Ps2_Key_Read(&keydata, &special, &down))// Any data from reader?
{
if (down && (keydata == 13)) // Is it the <Enter> Key?
{
data[BuffPtr] = 0; // For strcpy
Lcd_Out (1, 1, data); // Put Data read on Lcd
if (Button(&PORTA, 3, 1, 0)) // If button A3 pressed, save data.
{
strcpy (old_data, data);
for (i = 0; i < 20u; i++)
EEprom_Write(i, data[i]);
sound (2); // Just to warn that we are done
} // If (Button(&PORTC...
else // No, the button C7 is'nt pressed.
{
if (strcmp(data, old_data) == 0)
{
PORTB.F3 = 1; // Turn Rele on
sound (1); // Sinalize
Delay_ms (4000); // Wait 4 seconds
PORTB.F3 = 0; // Turn Rele off
}
else
{
PORTB.F3 =0; // Turn Rele off
sound (4); // Warn
}
}
BuffPtr = 0; // Reset Read Buffer pointer
memset (data, 0, 20); // Clean Buffer
Lcd_Out (2, 1, Old_data);//Put old data on Lcd
Delay_ms (3000); // Wait 3 seconds
Lcd_Cmd (LCD_CLEAR); // Then, clear the Lcd
} // if (down &
else if (down && !special && keydata)
{
data [BuffPtr++] = keydata; // It is not an <enter>
} // else if...
} // if (Ps2_Key_Read...
} while (1);
}//~
/*****************************************************************************/
// Sound routine (to spare memory):
void sound (unsigned short ntimes)
{
for (i=0; i<=ntimes; i++)
{
BUZZER = 1; //Buzzer on
Delay_ms (100); //Wait 100 ms
BUZZER = 0; //Buzzer off
Delay_ms (100); //Wait 100 ms
}
}
/*****************************************************************************/
What I am doing wrong?
I didn't find anything in the compiler manual.
Thanks for any help.
Sergio