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

PIC24FJ64GA006 + keyboard 4x4 doesn't work

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



Joined: 03 Aug 2010
Posts: 38

View user's profile Send private message MSN Messenger

PIC24FJ64GA006 + keyboard 4x4 doesn't work
PostPosted: Mon Aug 27, 2012 7:06 am     Reply with quote

Hi. I have a problem using the PIC24. when I compile the code using the library flex_kbd.c, there are many errors. I don't know why, I can't find the mistake. If I try the same code, using other microcontroller like PIC18F4550, it's works perfectly. Will it be a compiler mistake? Embarassed Can someone help me??

Code:

#include <24FJ64GA006.h>
#device adc=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOJTAG                   //JTAG disabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES ICSP2                    //ICD uses PGC2/PGD2 pins
#FUSES WINDIS                   //Watch Dog Timer in non-Window mode
#FUSES WPRES128                 //Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16                 //Watch Dog Timer PostScalar 1:32768
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES HS                       
#FUSES NOCKSFSM                 
#FUSES NOOSCIO                  //OSC2 is clock output
#FUSES PR                        //Pimary oscillaotr disabled

#use delay(clock=20000000)

#define _HDM64GS12
#define GLCD_CS1         PIN_E2
#define GLCD_CS2         PIN_E7
#define GLCD_DI        PIN_E3

#define GLCD_RW          PIN_E4
#define GLCD_E          PIN_E5                  
#define GLCD_RST        PIN_E6

//#define _ds1307
//#define RTC_SDA   PIN_F0
//#define   RTC_SCL   PIN_F1

//#define _flex_kbd_4x4                  
//#define col0 PIN_E0
//#define col1 PIN_E1
//#define col2 PIN_E2
//#define col3 PIN_E3
//#define row0 PIN_E4
//#define row1 PIN_E5
//#define row2 PIN_E6
//#define row3 PIN_E7

//#define _mcp41010
//#define CS             PIN_B7
//#define SCLK          PIN_B5
//#define SI             PIN_B6



#include <HDM64GS12.c>
#include <graphics.c>
#include <flex_kbd.c>                        
#include <clabe_acceso_lcd_grafico.c>
//#include <mcp41010.c>
#include <ds1307.c>
#include <ds1307_configuracion_lcd_grafico.c>

char valor_date[10];
char valor_lm35[5];
long medicion;

                              
void main(void)
{
//   setup_adc_ports (sAN9);           
     setup_adc (ADC_CLOCK_INTERNAL);                                
     set_adc_channel(0);                                             
     delay_us(10);


//SET_PULLUP(PIN_B0);

// #rom int8 0xF00004={'1','2','3','4'};                     

retardo=250;                            

//glcd_init(ON);
kbd_init();
 
//enable_interrupts(int_ext);
//ext_int_edge(L_TO_H);
//enable_interrupts(GLOBAL);


//set_pot (150);
output_high(PIN_B0);
//INICIO_CLABE_ACCESO();


do 
{

output_low(PIN_B0);
delay_ms(250);


   }while(TRUE);
 

}

Code:

///////////////////////////////////////////////////////////////////////////
////                             Flex_KBD.C                            ////
////                  Generic keypad scan driver                       ////
////                                                                   ////
////  kbd_init()   Must be called before any other function.           ////
////                                                                   ////
////  c = kbd_getc(c)  Will return a key value if pressed or /0 if not ////
////                   This function should be called frequently so as ////
////                   not to miss a key press.                        ////
////                                                                   ////
///////////////////////////////////////////////////////////////////////////
 
 
 
//Keypad connection:   
 
#ifndef _FLEX_KBD                  //directivas del pre-procesador
#define col0 PIN_E1
#define col1 PIN_A5
#define col2 PIN_C0
#define row0 PIN_E0 
#define row1 PIN_C2
#define row2 PIN_C1
#define row3 PIN_E2
#endif                           //directivas del pre-procesador 

// Keypad layout:
char const KEYS[4][3] = {{'1','2','3'},
                         {'4','5','6'},
                         {'7','8','9'},
                         {'*','0','#'}};
 
#define KBD_DEBOUNCE_FACTOR 33    // Set this number to apx n/333 where
                                  // n is the number of times you expect
                                  // to call kbd_getc each second
 
 
 
void kbd_init() {
}
 
 
short int ALL_ROWS (void)
{
   if (input (row0) & input (row1) & input (row2) & input (row3))
      return (0);
   else
      return (1);
}
 
 
 
char kbd_getc( ) {
   static byte kbd_call_count;
   static short int kbd_down;
   static char last_key;
   static byte col;
 
   byte kchar;
   byte row;
 
   kchar='\0';
   if(++kbd_call_count>KBD_DEBOUNCE_FACTOR) {
       switch (col) {
         case 0   : output_low(col0);
               output_high(col1);
               output_high(col2);
                    break;
         case 1   : output_high(col0);
               output_low(col1);
               output_high(col2);
                    break;
         case 2   : output_high(col0);
               output_high(col1);
               output_low(col2);
                    break;
       }
 
       if(kbd_down) {
         if(!ALL_ROWS()) {
           kbd_down=false;
           kchar=last_key;
           last_key='\0';
         }
       } else {
          if(ALL_ROWS()) {
             if(!input (row0))
               row=0;
             else if(!input (row1))
               row=1;
             else if(!input (row2))
               row=2;
             else if(!input (row3))
               row=3;
             last_key =KEYS[row][col];
             kbd_down = true;
          } else {
             ++col;
             if(col==3)
               col=0;
          }
       }
      kbd_call_count=0;
   }
  return(kchar);
}


Executing: "C:\Program files\Picc\CCSC.exe" +FD "Principal2.c" I+="C:\Program Files\PICC\Drivers;C:\Program Files\PICC\Devices;D:\PICS\Familias\Librerias_ccs_c(respaldar)" +DF +LN +T +A +M +Z +Y=9 +EA

>>> Warning 206 "C:\Program Files\PICC\Drivers\graphics.c" Line 531(1,1): Variable of this data type is never greater than this constant

*** Error 28 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 43(11,14): Expecting an identifier
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 43(20,21): Expecting a declaration
*** Error 81 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 44(1,2): Expecting a basic type
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(4,6): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(7,8): Expecting a declaration
*** Error 28 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(19,20): Expecting an identifier
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(21,22): Expecting a declaration
*** Error 29 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(38,39): Function definition different from previous definition
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(44,45): Expecting a declaration
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(49,50): Expecting a (
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(51,52): Expecting a declaration
*** Error 28 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(64,65): Expecting an identifier
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 45(65,66): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 46(7,13): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 46(14,15): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 46(15,16): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 46(16,17): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 46(17,18): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 47(4,8): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 48(7,13): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 48(14,15): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 48(15,16): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 48(16,17): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 48(17,18): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 49(1,2): Expecting a declaration
*** Error 28 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 55(21,24): Expecting an identifier
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 55(29,30): Expecting a declaration
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 62(4,9): Expecting a (
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 62(10,14): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 62(14,15): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 63(4,6): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 63(6,7): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 63(7,9): Expecting a declaration
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 63(9,23): Expecting a (
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 63(43,44): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 63(43,44): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 63(45,46): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 64(8,14): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 64(15,16): Expecting a declaration
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 64(16,19): Expecting a (
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 64(21,22): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 65(10,14): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 65(15,16): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 65(19,20): Expecting a declaration
*** Error 28 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 65(36,37): Expecting an identifier
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 65(37,38): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 68(21,26): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 68(26,27): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 69(10,14): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 69(15,16): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 69(19,20): Expecting a declaration
*** Error 28 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 69(37,38): Expecting an identifier
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 69(38,39): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 72(21,26): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 72(26,27): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 73(10,14): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 73(15,16): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 73(19,20): Expecting a declaration
*** Error 28 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 73(37,38): Expecting an identifier
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 73(38,39): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 76(21,26): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 76(26,27): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 77(8,9): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 79(8,10): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 79(10,11): Expecting a declaration
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 79(11,19): Expecting a (
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 79(21,22): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 80(10,12): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 80(12,13): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 80(13,14): Expecting a declaration
*** Error 29 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 80(26,27): Function definition different from previous definition
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 81(12,20): Expecting a (
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 81(26,27): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 81(26,27): Expecting a declaration
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 82(12,17): Expecting a (
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 82(18,26): Expecting a (
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 83(12,20): Expecting a (
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 83(21,25): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 83(25,26): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 84(10,11): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 85(8,9): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 85(10,14): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 85(15,16): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 86(11,13): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 86(13,14): Expecting a declaration
*** Error 29 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 86(26,27): Function definition different from previous definition
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 87(14,16): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 87(16,17): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 87(17,18): Expecting a declaration
*** Error 28 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 87(29,30): Expecting an identifier
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 87(30,31): Expecting a declaration
*** Error 48 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 88(16,19): Expecting a (
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 88(20,21): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 88(21,22): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 89(14,18): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 89(19,21): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 89(21,22): Expecting a declaration
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 89(22,23): Expecting a declaration
*** Error 29 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 90(16,17): Function definition different from previous definition
*** Error 43 "C:\Program Files\PICC\Drivers\flex_kbd.c" Line 90(19,20): Expecting a declaration
100 Errors, 1 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Mon Aug 27 10:01:16 2012
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 27, 2012 1:52 pm     Reply with quote

Most of the user code that is posted in this forum is for 16F or 18F PICs.
It's for the PCM or PCH compilers. The PCD compiler has different
data types than all the other CCS compilers.

For example, this data type in flex_kbd.c is causing an error with PCD:
Quote:

short int

Find all instances of that, and replace it with: int1
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