hello!
I am working on a matrice keypad programme. I am using MikroC compiler for PIC to write the code in. The code is basicly very similar to other matrice keypad codes, but i have problems with one of my variables called "spremenljivka". I would love to see someone help me with this, and if there is any other problem, since when i build the programme, it also sais internal eroor. I've been struggeling with this problem for some time now and am really confused, since i know that this problem occurres when 2 variables are defined differently, or when the variable is already used in C's liberary. Here is the code:
void port_ini(){
Keypad_Init(&PORTD);
}
unsigned short i, kp,cnt;
unsigned short spremenljivka[1], spremenljivka[2], spremenljivka[3], spremenljivka[4];
unsigned short code1;
void testirajtipke(){
do {
kp = 0;
//--- Wait for key to be pressed
do
//--- un-comment one of the keypad reading functions
kp = Keypad_Released();
//kp = Keypad_Read();
while (!kp);
switch (kp)
{
case 1: kp = '1'; break; // 1
case 2: kp = '2'; break; // 2
case 3: kp = '3'; break; // 3
case 5: kp = '4'; break; // 4
case 6: kp = '5'; break; // 5
case 7: kp = '6'; break; // 6
case 9: kp = '7'; break; // 7
case 10: kp = '8'; break; // 8
case 11: kp = '9'; break; // 9
case 13: kp = 42; break; // *
case 14: kp = 48; break; // 0
case 15: kp = 35; break; // #
}
code1 = kp;
Lcd_Init(&PORTB);
Lcd_Chr(2, i+1, code1); // Print key ASCII value on Lcd
i++;
}while (1);
}
void branje(){
Delay_ms(20);
spremenljivka[1] = EEPROM_Read(0x00); // beri podatke iz naslova 0
Delay_ms(20);
spremenljivka[2] = EEPROM_Read(0x01); // beri podatke iz naslova 1
Delay_ms(20);
spremenljivka[3] = EEPROM_Read(0x02); // beri podatke iz naslova 2
Delay_ms(20);
spremenljivka[4] = EEPROM_Read(0x03); // beri podatke iz naslova 3
Delay_ms(20);
}
void pisanje() {
{
Delay_ms(20);
EEPROM_Write(0x00,code1[0]); // piši podatke na naslov 00
Delay_ms(20);
EEPROM_Write(0x01,code1[1]); // piši podatke na naslov 01
Delay_ms(20);
EEPROM_Write(0x02,code1[2]); // piši podatke na naslov 02
Delay_ms(20);
EEPROM_Write(0x03,code1[3]); // piši podatke na naslov 03
}
}
void spremeni()
{
Lcd_Cmd(_LCD_CLEAR); // ponastavi LCD
Lcd_Out(1, 1, "vnseite novo kodo");
i=0;
testirajtipke();
testirajtipke();
testirajtipke();
testirajtipke();
pisanje();
branje();
}
void main ()
{
port_ini();
TRISC=0x00
ADCON1 |= 0x07;
Lcd_Init() ;
//osnovna koda je 1234, če v EEPROMU še ni shranjene kode
if(spremenljivka[1] == 0xFF && spremenljivka[2] == 0xFF && spremenljivka[3] == 0xFF && spremenljivka[4] == 0xFF )
{
EEPROM_Write(0x00,'1'); // Piši podatke na naslov 00
Delay_ms(20);
EEPROM_Write(0x01,'2'); // Piši podatke na naslov 01
Delay_ms(20);
EEPROM_Write(0x02,'3'); // Piši podatke na naslov 02
Delay_ms(20);
EEPROM_Write(0x03,'4'); // Piši podatke na naslov 03
}
branje();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 1, "Preverjam..." );
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
cnt=0;
do
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2, 3, "Pritisnite *");
i = 0;
testirajtipke();
if(code1[0] == 42) // po pritisku na * lahko začnemo vnašati geslo
{
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1, 1,"Vnesite geslo");
delay_ms(500);
i = 0;
testirajtipke();
testirajtipke();
testirajtipke();
testirajtipke();
if(code1[0] == '1' && code1[1] == '2' && code1[2] == '3' && code1[3] == '4' ) //check master code
{
testirajtipke();
if(code1[5] == 35) // če po vnesenemu geslu kliknemo še # se izvede pšrogram za ponastavitev gesla
{
spremenikodo();
}
}
if(cnt<3 && code1[0] == spremenljivka[1] && code1[1] == spremenljivka[2] && code1[2] == spremenljivka[3] && code1[3] == spremenljivka[4] && code1[4] == 35) //primerjanje s kodo v EEMPROM-u
{
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1, 1, "VSTOP ODOBREN" );
PORTC.F1 =0;
Delay_ms(1000);
PORTC.F1 =1;
}
else
{
cnt++;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "VSTOP ZAVRNJEN" );
}
if(cnt>=3) // če LCD izpiše vstop zavrnjen 3-krat ali več, se vklopi alarm
{
do
{
PORTC.F2=1;
}while(1);
}
}
}while(1);
}
errors with identifier redefined
General discussion on mikroC.
Author
Message
Jump to
- NECTO Studio
- ↳ IDE
- ↳ IDE General
- ↳ IDE Beta Testing
- ↳ IDE Wish List
- ↳ ARM AI Compilers
- ↳ mikroC AI for ARM
- ↳ mikroC AI for ARM General
- ↳ mikroC AI for ARM Beta Testing
- ↳ mikroC AI for ARM Wish List
- ↳ PIC AI compilers
- ↳ mikroC AI for PIC
- ↳ mikroC AI for PIC General
- ↳ mikroC AI for PIC Beta Testing
- ↳ mikroC AI for PIC Wish List
- ↳ PIC32 AI Compilers
- ↳ mikroC AI for PIC32
- ↳ mikroC AI for PIC32 General
- ↳ mikroC AI for PIC32 Beta Testing
- ↳ mikroC AI for PIC32 Wish List
- ↳ dsPIC AI Compilers
- ↳ mikroC AI for dsPIC
- ↳ mikroC AI for dsPIC General
- ↳ mikroC AI for dsPIC Beta Testing
- ↳ mikroC AI for dsPIC Wish List
- ↳ AVR AI Compilers
- ↳ mikroC AI for AVR
- ↳ mikroC AI for AVR General
- ↳ mikroC AI for AVR Beta Testing
- ↳ mikroC AI for AVR Wish List
- ↳ Additional Software
- ↳ Visual TFT AI
- ↳ Visual TFT AI General
- ↳ Visual TFT AI Beta Testing
- ↳ Visual TFT AI Wish List
- PRO Compilers
- ↳ PIC PRO Compilers
- ↳ PIC Compilers General
- ↳ mikroC PRO for PIC
- ↳ mikroC PRO for PIC General
- ↳ mikroC PRO for PIC Beta Testing
- ↳ mikroC PRO for PIC Wish List
- ↳ mikroBasic PRO compiler for PIC
- ↳ mikroBasic PRO for PIC General
- ↳ mikroBasic PRO for PIC Beta Testing
- ↳ mikroBasic PRO for PIC Wish List
- ↳ mikroPascal PRO for PIC
- ↳ mikroPascal PRO for PIC General
- ↳ mikroPascal PRO for PIC Beta Testing
- ↳ mikroPascal PRO for PIC Wish List
- ↳ dsPIC PRO Compilers
- ↳ dsPIC Compilers General
- ↳ mikroC PRO for dsPIC30/33 and PIC24
- ↳ mikroC PRO for dsPIC30/33 and PIC24 General
- ↳ mikroC PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroC PRO for dsPIC30/33 and PIC24 Wish List
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 General
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 Wish List
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 General
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 Wish List
- ↳ PIC32 PRO Compilers
- ↳ PIC32 Compilers General
- ↳ mikroC PRO for PIC32
- ↳ mikroC PRO for PIC32 General
- ↳ mikroC PRO for PIC32 Beta Testing
- ↳ mikroC PRO for PIC32 Wish List
- ↳ mikroBasic PRO for PIC32
- ↳ mikroBasic PRO for PIC32 General
- ↳ mikroBasic PRO for PIC32 Beta Testing
- ↳ mikroBasic PRO for PIC32 Wish List
- ↳ mikroPascal PRO for PIC32
- ↳ mikroPascal PRO for PIC32 General
- ↳ mikroPascal PRO for PIC32 Beta Testing
- ↳ mikroPascal PRO for PIC32 Wish List
- ↳ AVR PRO Compilers
- ↳ AVR Compilers General
- ↳ mikroC PRO for AVR
- ↳ mikroC PRO for AVR General
- ↳ mikroC PRO for AVR Beta Testing
- ↳ mikroC PRO for AVR Wish List
- ↳ mikroBasic PRO compiler for AVR
- ↳ mikroBasic PRO for AVR General
- ↳ mikroBasic PRO for AVR Beta Testing
- ↳ mikroBasic PRO for AVR Wish List
- ↳ mikroPascal PRO for AVR
- ↳ mikroPascal PRO for AVR General
- ↳ mikroPascal PRO for AVR Beta Testing
- ↳ mikroPascal PRO for AVR Wish List
- ↳ FT90x PRO Compilers
- ↳ FT90x Compilers General
- ↳ mikroC PRO for FT90x
- ↳ mikroC PRO for FT90x General
- ↳ mikroC PRO for FT90x Beta Testing
- ↳ mikroC PRO for FT90x Wish List
- ↳ mikroBasic PRO compiler for FT90x
- ↳ mikroBasic PRO for FT90x General
- ↳ mikroBasic PRO for FT90x Beta Testing
- ↳ mikroBasic PRO for FT90x Wish List
- ↳ mikroPascal PRO for FT90x
- ↳ mikroPascal PRO for FT90x General
- ↳ mikroPascal PRO for FT90x Beta Testing
- ↳ mikroPascal PRO for FT90x Wish List
- ↳ 8051 PRO Compilers
- ↳ 8051 Compilers General
- ↳ mikroC PRO for 8051
- ↳ mikroC PRO for 8051 General
- ↳ mikroC PRO for 8051 Beta Testing
- ↳ mikroC PRO for 8051 Wish List
- ↳ mikroBasic PRO compiler for 8051
- ↳ mikroBasic PRO for 8051 General
- ↳ mikroBasic PRO for 8051 Beta Testing
- ↳ mikroBasic PRO for 8051 Wish List
- ↳ mikroPascal PRO for 8051
- ↳ mikroPascal PRO for 8051 General
- ↳ mikroPascal PRO for 8051 Beta Testing
- ↳ mikroPascal PRO for 8051 Wish List
- ↳ ARM PRO Compilers
- ↳ ARM Compilers General
- ↳ mikroC PRO for ARM
- ↳ mikroC PRO for ARM General
- ↳ mikroC PRO for ARM Beta Testing
- ↳ mikroC PRO for ARM Wish List
- ↳ mikroBasic PRO for ARM
- ↳ mikroBasic PRO for ARM General
- ↳ mikroBasic PRO for ARM Beta Testing
- ↳ mikroBasic PRO for ARM Wish List
- ↳ mikroPascal PRO for ARM
- ↳ mikroPascal PRO for ARM General
- ↳ mikroPascal PRO for ARM Beta Testing
- ↳ mikroPascal PRO for ARM Wish List
- ↳ Older versions of Compilers
- ↳ Older versions of mikroC Compilers
- ↳ mikroC for PIC
- ↳ mikroC General
- ↳ mikroC Beta Testing
- ↳ mikroC Wish List
- ↳ mikroC for dsPIC30/33 and PIC24
- ↳ mikroC for dsPIC30/33 and PIC24 General
- ↳ mikroC for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroC for dsPIC30/33 and PIC24 Wish List
- ↳ RSC-4x mikroC
- ↳ RSC-4x mikroC General
- ↳ RSC-4x mikroC Wish List
- ↳ mikroC Beta testing
- ↳ Older versions of mikroBasic Compilers
- ↳ mikroBasic compiler for PIC
- ↳ mikroBasic General
- ↳ mikroBasic Beta Testing
- ↳ mikroBasic Wish List
- ↳ mikroBasic compiler for dsPIC30/33 and PIC24
- ↳ mikroBasic for dsPIC30/33 and PIC24 General
- ↳ mikroBasic for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroBasic for dsPIC30/33 and PIC24 Wish List
- ↳ mikroBasic for dsPIC30/33 and PIC24 Bug List
- ↳ Obsolete Project: mikroBasic compiler for AVR
- ↳ mikroBasic for AVR General
- ↳ mikroBasic for AVR Wish List
- ↳ mikroBasic Beta testing
- ↳ Older versions of mikroPascal Compilers
- ↳ mikroPascal compiler for PIC
- ↳ mikroPascal FAQ
- ↳ mikroPascal General
- ↳ mikroPascal Beta Testing
- ↳ mikroPascal Wish List
- ↳ mikroPascal Bug List
- ↳ mikroPascal compiler for dsPIC30/33 and PIC24
- ↳ mikroPascal for dsPIC30/33 and PIC24 General
- ↳ mikroPascal for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroPascal for dsPIC30/33 and PIC24 Wish List
- ↳ mikroPascal for dsPIC30/33 and PIC24 Bug List
- ↳ Obsolete Project: mikroPascal compiler for AVR
- ↳ mikroPascal for AVR General
- ↳ mikroPascal for AVR Wish List
- ↳ mikroPascal Beta testing
- ↳ Library Development Discussion
- ↳ Code Requests
- Additional Software
- ↳ Visual TFT Software
- ↳ Visual TFT General
- ↳ Visual TFT Beta Testing
- ↳ Visual TFT Wish List
- ↳ Visual GLCD Software
- ↳ Visual GLCD General
- ↳ Visual GLCD Beta Testing
- ↳ Visual GLCD Wish List
- ↳ Package Manager Software
- ↳ Package Manager General
- ↳ Package Manager Beta Testing
- ↳ Package Manager Wishlist
- ↳ GLCD Font Creator Software
- ↳ SpeakUp Software
- ↳ Timer Calculator
- ↳ CAN Calculator
- ↳ mikroBootloader
- Hardware
- ↳ Development Boards
- ↳ CODEGRIP programmer and debugger
- ↳ Mikromedia
- ↳ mikroProg™ programmer and debugger
- ↳ Development Boards Wishlist
- ↳ Review
- ↳ Click Boards release
- ↳ Hexiwear
- Website & Forums
- ↳ Libstock Discussion
- ↳ Product Announcements
- ↳ Website & Forums General Discussion
- ↳ Website & Forums Wishlist
- ↳ User Projects