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

Kbd1.c impossible to compile

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



Joined: 07 Feb 2005
Posts: 12

View user's profile Send private message

Kbd1.c impossible to compile
PostPosted: Mon Oct 05, 2009 10:38 am     Reply with quote

Hi all, I am looking to compile KBD1.c (key 4x4 with porta and portb) but it's impossible. It write's "undefined identifier Kbd_cols" in http://www.ccsinfo.com/forum/viewtopic.php?t=23467&highlight=kbd.
I'm using version 3.245.
Code:

///////////////////////////////////////////////////////////////////////////
////                             KBDD.C                                ////
////                  Generic keypad scan driver                       ////

++++++++++++++++++
Code deleted.
Reason: Forum Rule #10
10. Don't post the CCS example code or drivers

-- Forum Moderator
++++++++++++++++++


Principal code:
Code:

#include <SK18f4x2.h>

#use delay (clock=10000000)  // 10MHz pour l'emulation et 10 MHz pour la programmation
#include <sk4x2_driver_lcd.c>
//#include <sw_anti_rebond.c>
#include <KBD2.c.>

// fuses pour programmation définitive
#fuses HS, NOPROTECT, NOOSCSEN, BROWNOUT, NOWDT, BORV27, PUT, CCP2C1, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
//**************************************************************************/
//
// définitions de variables
byte string1[] = "Test de clavier";

//définitions des strings d'affichage
// technique utilisée:
// les pics n'autorisant pas de pointeur sur le code, il faut ruser!!
// on ne peut pas pointer sur le code mais on peut utiliser une variable de type array
// stockée en rom.
// On définit donc des strings de caractères en rom:

const int8 string_a_tous []   = {" de clavier "};
const int8 string_starter_kit []    = {"la touche est:"};

// puis un type énumération qui reprend les noms de ces lignes

typedef enum {e_string_a_tous, e_string_starter_kit} tstring_rom;
// que l'on utilisera pour retourner le caractère à afficher.
// pour trouver le bon caractère, on utilisera une fonction qui aura en entrée une valeur du type
// énuméré donnant la ligne que l'on désire afficher et l'ordre du caractère dans cette ligne
// cette fonction retournera le caractère à afficher.
// Pour l'affichage d'une ligne, on effectuera une boucle qui commencera par le premier caractère
// de la ligne et qui prendra les caractères suivants jusqu'au 00h.

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

int8 get_string_rom_char ( tstring_rom string_rom, int ordre) {
  switch (string_rom) {
    case e_string_a_tous: return (string_a_tous[ordre]);
    break;
    case e_string_starter_kit: return (string_starter_kit[ordre]);
    break;
  }
}
/********************************************************************************************/
/********************************************************************************************/

void display_string_rom (tstring_rom string_rom) {
int char_prov, char_cnt;
  char_cnt = 0;
  do {
    char_prov = get_string_rom_char(string_rom, char_cnt);
    if (char_prov != 0) {
      lcd_putc(char_prov);
    }
    char_cnt++;
  }
  while (char_prov != 0);
}
/********************************************************************************************/



void main()

{

   int8 k;
   //port_b_pullups(TRUE);
   //setup_adc_ports(NO_ANALOGS);
   lcd_bl_off();
   delay_ms(150);
   lcd_bl_on();
   lcd_init();
   kbd_init();
  // lcd_putc("\fPret...\n"); //Retour au premier caractère de la première ligne
lcd_putc("\r\S ...");


   while(1)
   {
      //Affichage

     // lcd_put_string_ram(&string1[0]);
     // display_string_rom (e_string_a_tous);
      //lcd_putc('\n'); //Retour au premier caractère de la deuxième ligne
      //display_string_rom (e_string_starter_kit);
      //delay_ms(500);
     // lcd_putc('\f'); //Retour au premier caractère de la première ligne
      //delay_ms(150);
      k=kbd_getc();      // Lecture clavier
      if(k!=0)
        if(k=='*')      // Si touche *
          lcd_putc('\f');   // Effacement de l’afficheur
        else
        //lcd_gotoxy(1,2);
          lcd_putc(k);      // Sinon affichage touche



}


}
kdoney34711



Joined: 05 Oct 2009
Posts: 6

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 11:09 am     Reply with quote

I am confused. In your principal <--? code you include "kdb2.c." but the kbd code is in kbdd.c? Should you have the period at the end of kbd2.c or should the include be kbdd.c?
_________________
KDONEY
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 11:41 am     Reply with quote

Quote:
#include <SK18f4x2.h>
#use delay (clock=10000000) // 10MHz pour l'emulation et 10 MHz pour la programmation
#include <sk4x2_driver_lcd.c>
//#include <sw_anti_rebond.c>
#include <KBD2.c.>

What is "SK18f4x2.h" ? Where is the #include line for the .h file for
your PIC ? Did you modify and rename the CCS #include file ?
(Don't do that). What PIC are you using ?
Cheick



Joined: 07 Feb 2005
Posts: 12

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 11:49 am     Reply with quote

The filename is KDB2.c Trying to compile this is impossible.
Cheick



Joined: 07 Feb 2005
Posts: 12

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 12:15 pm     Reply with quote

This is the sk18f4x2.h
Code:

// Ecole Technique LELN
// Modèle Kit minimal

#include <18F452.h>
#device adc=10
// fuses pour programmation définitive
#fuses HS, NOPROTECT, NOOSCSEN, BROWNOUT, NOWDT, BORV27, PUT, CCP2C1, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
#use delay (clock=10000000)  // 10MHz pour l'emulation et 10 MHz pour la programmation

// Re définition des entrées-sorties
#define Analog1   PIN_A0
#define Analog2   PIN_A1
#define LIGNE1    PIN_A2
#define LIGNE2    PIN_A3
#define LIGNE3    PIN_A4
#define LIGNE4    PIN_A5
//#define PIN_A6  31750

#define S_ESC_MENU   PIN_B0
#define S_PLUS       PIN_B1
#define S_MINUS      PIN_B2
#define S_OK         PIN_B3
#define COLONNE1     PIN_B4
#define COLONNE2     PIN_B5
#define COLONNE3     PIN_B6
#define COLONNE4     PIN_B7

#define I2C_SDA      PIN_C0
#define I2C_SCL      PIN_C1
#define CS_LM70      PIN_C2
#define SPI_SCL      PIN_C3
#define SPI_SDI      PIN_C4
#define SPI_SDO      PIN_C5
#define RS232_TX     PIN_C6
#define RS232_RX     PIN_C7

#define LCD_RS       PIN_D0
#define LCD_RW       PIN_D1
#define LCD_E        PIN_D2
#define LCD_BL       PIN_D3
#define LCD_DB4      PIN_D4
#define LCD_DB5      PIN_D5
#define LCD_DB6      PIN_D6
#define LCD_DB7      PIN_D7

#define RTS       PIN_E0
#define CTS       PIN_E1
#define LED_D1    PIN_E2
Cheick



Joined: 07 Feb 2005
Posts: 12

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 12:17 pm     Reply with quote

I use 18f452
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 12:31 pm     Reply with quote

Quote:
#if defined(__PCH__)

#if defined use_porta_kbd
#byte kbd_rows = 0xF80 // Port A on 18F452
#byte kbd_cols = 0xF81 // Port B on 18F452

#endif
#else
#byte kbd_rows = 5 // Port A on 16F877
#byte kbd_cols = 6 // Port B on 16F877
#endif

You have an #if statement, but you didn't define 'use_porta_kbd' in
your program. That's why it doesn't compile.

Edit your main program and add the line shown in bold below.
Put it in that exact position in the program.
Quote:

#include <SK18f4x2.h>

#use delay (clock=10000000) // 10MHz pour l'emulation et 10 MHz pour la programmation
#include <sk4x2_driver_lcd.c>
//#include <sw_anti_rebond.c>

#define use_porta_kbd 1
#include <KBD2.c.>
Cheick



Joined: 07 Feb 2005
Posts: 12

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 12:54 pm     Reply with quote

I have changed but there is nothing. This is the code that you posted
Code:

#include <SK18f4x2.h>
#use delay (clock=10000000)  // 10MHz pour l'emulation et 10 MHz pour la programmation
#include <sk4x2_driver_lcd.c>
//#include <sw_anti_rebond.c>
#include <KBD2.c.>
#define use_porta_kbd 1

// fuses pour programmation définitive
#fuses HS, NOPROTECT, NOOSCSEN, BROWNOUT, NOWDT, BORV27, PUT, CCP2C1, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
//**************************************************************************/
//
// définitions de variables
byte string1[] = "Test de clavier";

//définitions des strings d'affichage
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 12:56 pm     Reply with quote

Read my post again. Read the instructions carefully. Look at where I
put the #define statement.

Details are important.
Cheick



Joined: 07 Feb 2005
Posts: 12

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 1:08 pm     Reply with quote

PCM programmer wrote:
Read my post again. Read the instructions carefully. Look at where I
put the #define statement.

Details are important.


I have taken the code http://www.ccsinfo.com/forum/viewtopic.php?t=23467&highlight=kbd i've just changed the matrix to 4x4 instead of 4x3 but Kbd_cols not recognized and I don t understand why.
But when I took the source file kbd.c it compiles without problem.
I connected the keyboard port 2 a and b
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 1:25 pm     Reply with quote

Edit your main program and add the line shown in bold below.
Put it in that exact position in the program.
Quote:
#include <SK18f4x2.h>

#use delay (clock=10000000) // 10MHz pour l'emulation et 10 MHz pour la programmation
#include <sk4x2_driver_lcd.c>
//#include <sw_anti_rebond.c>

#define use_porta_kbd 1
#include <KBD2.c.>
Cheick



Joined: 07 Feb 2005
Posts: 12

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 1:48 pm     Reply with quote

PCM programmer wrote:
Edit your main program and add the line shown in bold below.
Put it in that exact position in the program.
Quote:
#include <SK18f4x2.h>

#use delay (clock=10000000) // 10MHz pour l'emulation et 10 MHz pour la programmation
#include <sk4x2_driver_lcd.c>
//#include <sw_anti_rebond.c>

#define use_porta_kbd 1
#include <KBD2.c.>





Thanks Laughing Laughing Its ok
Cheick



Joined: 07 Feb 2005
Posts: 12

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 2:42 pm     Reply with quote

My program works but the keyboard is unstable example when i press 2 it go out 1
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 05, 2009 3:14 pm     Reply with quote

Do you have pullup resistors on the Row pins of the keypad ?
You need them. You can use 10K ohm resistors.
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