pic 16f88 and eeprom

General discussion on mikroC.
Post Reply
Author
Message
ssaguiar
Posts: 42
Joined: 04 Mar 2005 22:15
Location: Florianopolis - Brazil

pic 16f88 and eeprom

#1 Post by ssaguiar » 10 Nov 2005 02:52

Dear friends :

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
    }
}

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

I ask:

What I am doing wrong?

I didn't find anything in the compiler manual.

Thanks for any help.

Sergio

pizon
mikroElektronika team
Posts: 823
Joined: 11 Oct 2004 08:53

Re: pic 16f88 and eeprom

#2 Post by pizon » 10 Nov 2005 09:27

We forgot to include the EEPROM library in the definition file for th 16F88. Open the <>\Defs\P16F88.mlk file, go to the //LIBRARY section and insert the EEPROMlib_E_A library there, i.e. alter the 2nd line to be:

Code: Select all

#pragma SetLib(usartlib_U_F,  EEPROMlib_E_A)
We will correct this.
pizon

ssaguiar
Posts: 42
Joined: 04 Mar 2005 22:15
Location: Florianopolis - Brazil

thanks

#3 Post by ssaguiar » 10 Nov 2005 11:35

I´ll do this.

Thank you very much for your suport.

Sergio

alvinthen
Posts: 1
Joined: 05 Mar 2011 04:38

Re: pic 16f88 and eeprom

#4 Post by alvinthen » 05 Mar 2011 04:42

Hi, sorry for bringing up such an old post.
I'm currently doing a project which require a barcode scanner to be interfaced with PIC18F2220.
I've read through the PS/2 protocol, but can i assume the barcode scanner is working exactly like a keyboard?
Would you mind sharing the library file needed for PS/2 protocol? (The header file which includes the definition of Ps2_Init() etc)

Thank you very much for your help!

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: pic 16f88 and eeprom

#5 Post by tihomir.losic » 11 Mar 2011 16:06

Hello,

here you have similar topic, and I hope that it will help to you.
http://www.mikroe.com/forum/viewtopic.php?f=88&t=29907

Best regards,

Losic Tihomir
mikroElektronika [Support team]

Post Reply

Return to “mikroC General”