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 support@ccsinfo.com

kbd.c compiling error

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



Joined: 12 Dec 2017
Posts: 3

View user's profile Send private message

kbd.c compiling error
PostPosted: Fri Dec 15, 2017 12:13 am     Reply with quote

Hello,
I have a program that uses kbd.c, but when I try to compile it, I get an error, not in my program but in kbd.c:
*** Error 28 "C:\Program Files\PICC\Drivers\kbd.c" Line 32(34,35): Expecting an identifier Bad SFR name
I'm compiling for a PIC18F2550. I've compiled this program in other PCs with no errors, but I don't know what's wrong with my configuration.
If you need to see the program, here it is:
Code:

#include <18f2550.h>
#fuses XT,WDT128,CPUDIV1,MCLR
#USE delay(clock=20M,restart_wdt)
#use fast_io(b)
#use standard_io(c)

#define LCD_DATA_PORT getenv("SFR:PORTB")


#define use_portb_kbd true
#include <kbd.c>
#include <lcd.c>
#include <tones.c>
#rom int8 0xf00000 ={'8','9','2','8','7','0','4','3','6'} // Password de 9 dígitos (nuevo)
#zero_ram

void sonido();

void main()
{
  char k;
  int i;
  volatile char data[9], clave[9];  // 9 dígitos en los arreglos (nuevo)

  port_b_pullups(true);
  lcd_init();
  kbd_init();
  lcd_gotoxy(1,1);
  printf(lcd_putc,"Practica 5");
  delay_ms(1000);
  output_low(pin_C0);
  while (TRUE) {
  i=0;            //posici�n de la matriz
  lcd_gotoxy(1,1);
  printf(lcd_putc,"\fIngresa Digito 1\n");  //Para primer dato
  while(i<9){                //Para 8 datos (nuevo)
    k=kbd_getc();            //Lee el teclado
    if (k!=0)                //Si se ha pulsado alguna tecla
       {data[i]=k;           //se guarda en la posici�n correspondiente
        i++;                //de la matriz
        lcd_gotoxy(1,1);
        if(i > 8)  // Se intenta abrir el candado cuando se han ingresado 9 dígitos (nuevo)
          printf(lcd_putc,"\fEspere ....  ");  //Siguiente dato
        else
          printf(lcd_putc,"Ingresa Digito %u     ",i+1);  //Siguiente dato
          lcd_gotoxy(1,2);
          printf(lcd_putc,"Clave= %s        ",data);
       }
    }
   delay_ms(1000);
   for (i=0;i<=8;i++) {             //Pasa datos de eeprom a la matriz clave, con 9 dígitos (nuevo)
     clave[i]=read_eeprom(i);
     }

   if ((data[0]==clave[0])&&(data[1]==clave[1])&&(data[2]==clave[2])&&(data[3]==clave[3])&&(data[4]==clave[4])&&(data[5]==clave[5])&&(data[6]==clave[6])&&(data[7]==clave[7])&&(data[8]==clave[8]))
      { printf(lcd_putc,"\fPuerta Abierta"); //Compara los datos con la clave
        output_high(PIN_C0);                //Si es igual da pulso al rel�
        delay_ms(1000);
        output_low(PIN_C0);
        for (int j = 0; j<9; j++) { // Borrando los datos ingresados (nuevo)
          data[j] = 0;
        }
        #ASM
         RESET
        #ENDASM
      }
   else{
   sonido();
   lcd_gotoxy(1,1);
   printf(lcd_putc,"\fClave erronea");
   lcd_gotoxy(1,2);
   printf(lcd_putc,"Puerta Cerrada");  //Clave erronea
   }
   delay_ms(10000);
   }
}

void sonido () // Nueva canción (nuevo)
{
    long sou[]={62,125,250,500,1000,2000};
         generate_tone(F_NOTE[3],sou[1]);
         generate_tone(C_NOTE[3],sou[0]);
         generate_tone(C_NOTE[3],sou[0]);
         generate_tone(E_NOTE[3],sou[1]);
         generate_tone(C_NOTE[3],sou[3]);
         generate_tone(E_NOTE[3],sou[1]);
         generate_tone(F_NOTE[3],sou[1]);
}

Thanks
Haniver



Joined: 12 Dec 2017
Posts: 3

View user's profile Send private message

Actually, there are many errors
PostPosted: Fri Dec 15, 2017 12:24 am     Reply with quote

Actually, there are many compiling errors:
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Fri Dec 15, 2017 1:29 am     Reply with quote

#define LCD_DATA_PORT getenv("SFR:PORTB")

Tells the LCD driver to use PortB.

#define use_portb_kbd true

Tells the keyboard driver to use PortB......

They can't both use the same port.

The tones driver is also trying to use B0:

#define TONE_PIN PIN_B0

There are also configuration problems with your code. Currently it is trying to use a crystal oscillator rated for 4MHz max, but run at 20MHz.

You need to do things one part at a time:

1) Get your processor running. Test it is running at the right speed with a simple 'flash an LED' test.
2) Then honestly I'd suggest using the flex_lcd driver (in the code library). This allows you to specify the individual pins used for the LCD. Get this working using pins that are not wanted for the keyboard.
3) Once this is running, get the keyboard driver working.
4) Only then get the tone driver working.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Dec 15, 2017 10:34 am     Reply with quote

also....
with reference to this....
Quote:
#USE delay(clock=20M,restart_wdt)
#use fast_io(b)
#use standard_io(c)

5) delete, restart_wdt // NOT needed for now

6) delete fast_io() // unless you're a skilled programmer, let teh compiler handle this auotmatically !

7) delete standard_io() // again let the compiler do it automatically !


As Mr T says do ONE thing at a time,get it working THEN proceed to the next bit of code.
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