Hola a todos. Estoy trabajando en un proyecto...es como un sistema de seguridad. Ahorita lo que estoy haciendo es el menu con el lcd y el keypad. Estoy utilizando el PIC18F4220 y estoy programando en mikroC PRO. Lo que se va a poder a hacer con el sistema es 1. activar y desactivar el sistema, 2. poner y cambiar el password de el sistema y 3. escojer una frequencia. Esto es lo que llevo hasta ahorita....
Mi problema es que me me da un error de "recurrsion or cross-calling". No estoy segura si voy en buenos pasos. Me pregunto si alguien por aqui a trabajado en algo similar que me pudiera ayudar. Mi disenio lo estoy probando en Proteus...ahi ya tengo las conexiones necesarias. Muchas gracias!
Código:
//Start of program
#pragma config MCLRE = ON //Enable master clear input
unsigned short kp; //Defining variables kp and i and array oldstate
char txt[6]; //Defining array "txt"of type character
char keypadPort at PORTD; //Setting up Keypad at Port D
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
void initMain(){ //Main initialization of SFR registers
INTCON = 0x00;
ADRESH = 0x00;
ADRESL = 0x00;
ADCON1 = 0x0F; //Set all pins to digital I/O
ADCON0 = 0x00;
TRISD = 0xFF;
TRISB = 0x00;
PORTB = 0x00;
PORTD = 0x00;
}
void main_menu(void); //Defining main_menu function
void read_keypad(void); //Defining read_keypad function
char menus(char x); //Defining menus function
void sys_act(void);
void password(void);
void main() { //Main method
initMain(); //Main initialization
Keypad_Init(); //Initialize Keypad
Lcd_Init(); //Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 4, "SECDET SECURITY"); //Printing out "SECDET SECURITY" on LCD's 1st Row
Delay_ms(1500); //1500 ms Delay before clearing LCD display
Lcd_Cmd(_LCD_CLEAR); //Clear LCD Display
main_menu(); //Calling on main_menu function
} //End of Main()
void main_menu(void){ //main_menu function
//Printing out the system's main menu on the LCD screen
Lcd_Out(1, 7, "Main Menu");
Lcd_Out(2, 1, "1 Act./Deact.");
Lcd_Out(3, 1, "2 Password");
Lcd_Out(4, 1, "3 Frequency");
read_keypad(); //Calling on the read_keypad function
} //End of main_menu function
void read_keypad(void){ //read_keypad function
do { //Infinite loop
kp = 0; //Initializing variable "kp" to zero
while (!kp){ //Wait for key to be pressed and released
kp = Keypad_Key_Click(); //If no key is clicked, returns 0.
Delay_ms(10); //10 ms delay
} //End of while
switch (kp) { // Prepare value for output. Check which key was pressed.
case 1: kp = '1'; break;
case 2: kp = '2'; break;
case 3: kp = '3'; break;
case 5: kp = '4'; break;
case 6: kp = '5'; break;
case 7: kp = '6'; break;
case 9: kp = '7'; break;
case 10: kp = '8'; break;
case 11: kp = '9'; break;
case 13: kp = '*'; break;
case 14: kp = '0'; break;
case 15: kp = '#'; break;
default: kp = 0;
} //End of switch case for keypad
menus(kp); //Calling on the menus function and passing the value of the key pressed on keypad sys_act(kp);
} while (1); //End of the infinite loop
} //End of read_keypad function
char menus(char x){ //menus function
switch(kp){
case '1': Delay_ms(100);
Lcd_Cmd(_LCD_CLEAR); //Clear LCD Display
Lcd_out(1, 1, "1 Activate System");
Lcd_out(2, 1, "2 Deactivate System");
Lcd_out(3, 1, "* Back");
sys_act();
break;
case '2': Lcd_Cmd(_LCD_CLEAR); //Clear LCD Display
Lcd_out(1, 1, "1 Change Password");
Lcd_out(2, 1, "* Back");
break;
}
} //End of menus function
void sys_act(void){
if(kp=='1'){
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); //Clear LCD Display
Lcd_out(1, 1, "hello");
}
if(kp=='3'){
main_menu();
}
}
Mi problema es que me me da un error de "recurrsion or cross-calling". No estoy segura si voy en buenos pasos. Me pregunto si alguien por aqui a trabajado en algo similar que me pudiera ayudar. Mi disenio lo estoy probando en Proteus...ahi ya tengo las conexiones necesarias. Muchas gracias!