[newbie] Help! Strange messages

General discussion on mikroC.
Post Reply
Author
Message
robymak
Posts: 47
Joined: 08 Apr 2012 19:41

[newbie] Help! Strange messages

#1 Post by robymak » 09 Apr 2012 11:59

Hi,
I'm using an LCD to indicate various information and functions of keypad4x4, the strings are many and I've included simply in the program as text variables.
I see a problem that, from a certain point, appear on LCD of random strings, other than those specifically selected and mixed together.
I'm using a 18F452 with 14% RAM and 8% ROM being used, the board EasyPIC5 and mikroC-Pro (registered).
I use the internal EEPROM for data only fixed the default and the data that I can change.

:cry: What are my mistakes?
:cry: What should I do?


Many thanks in advance for your help and your cooperation,

Roberto

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: [newbie] Help! Strange messages

#2 Post by janko.kaljevic » 10 Apr 2012 15:04

Hello,

Please can you post an example for this, so we can test it.
It would be he best and fastest way to help you with this project.

Best regards.

robymak
Posts: 47
Joined: 08 Apr 2012 19:41

Re: [newbie] Help! Strange messages

#3 Post by robymak » 10 Apr 2012 17:09

Many thanks Janko, here the code...

/* CPU UTILIZZATA 18F452
dopo che un warning del compilatore che aveva indicato la 16F887
incapace di gestire le troppe variabili

DATI STANDARD FUSIONE memorizzati in EEPROM
equazione retta °C = ((t-t1/t2-t1)*(°C2- °C1)) + °C1
t0 = inizio T0 = Temperatura ambiente
t1 = 60 secondi T1 = 130°C °C = (( t/60 * (130-T0))+T0
t2 = 180 sec T2 = 185°C °C = (( t-60) * 0,458 ) + 130
t3 = 240 sec T3 = 250°C °C = (( t-180) * 1,083) + 185
t4 = 300 sec T4 = 250°C mantenimento temperatura a 250°C per 60 sec
t5 = 360 sec T5 = 120°C °C = (( t-300) * -2,166) + 250
*/

unsigned short fase = 0, oldstate = 0, knr, lun, kp, kp2, cnt;
unsigned short N1, change , flag_function, countkey = 0;
unsigned short d01, d11, d22, da, daa, d33;
int *num, i, j, lsb, msb, *TR, pos1 = 1, pos2 = 11;
unsigned int AA=0, BB=0, CC=0, DD ;
unsigned int dato, nn, addr;
char *nr, testo[20], txt, t0[7], t1[7], k, base, *ff;
char _pos, EE[8], *ptr, *_txt=" ";
extern void F1();
extern void F2();
extern void F3();
extern void F4();

int LeggiDati(int,int);
int LeggiNum(int,int);
void Delay_us();
void Vdelay_ms();
void impulso();

// Keypad 4x4 module connections
char keypadPort at PORTC;
// Lcd 4x20 module connections init
sbit LCD_RS at RD4_bit;
sbit LCD_EN at RD5_bit;
sbit LCD_D4 at RD0_bit;
sbit LCD_D5 at RD1_bit;
sbit LCD_D6 at RD2_bit;
sbit LCD_D7 at RD3_bit;
sbit LCD_D4_Direction at TRISD0_bit;
sbit LCD_D5_Direction at TRISD1_bit;
sbit LCD_D6_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD3_bit;
sbit LCD_EN_Direction at TRISD5_bit;
sbit LCD_RS_Direction at TRISD4_bit;

extern void F1() { //Tasto "A" Temp.Riscald.
lun= 3;
fase = 1;
LCD_Cmd(_LCD_CLEAR);
LeggiDati(0x00, 1);
LeggiNum(0xC0, 1);
LeggiDati(0x90, 2);
}

extern void F2() { //Tasto"B" Durata Riscald
lun= 4;
fase = 2;
LCD_Cmd(_LCD_CLEAR);
LeggiDati(0x10, 1);
LeggiNum(0xD0, 1);
LeggiDati(0x90, 2);
}

extern void F3() { //Tasto"C" Temp.fusione
lun= 3;
fase = 3;
LeggiDati(0x20, 1);
LeggiNum(0xE0, 1);
LeggiDati(0x90, 2);
}

extern void F4() { //Tasto"D" Durata fusione
lun= 4;
fase = 4;
LeggiDati(0x30, 1);
LeggiNum(0xF0, 1);
LeggiDati(0x90, 2);
}
int LeggiDati(int _addr, int _row) {
char EE[8], *ptr;

unsigned int AA=0, BB=0, CC=0, DD;

AA = (EEprom_Read(_addr))-48;
BB = (EEprom_Read(_addr + 1))-48;
CC = (EEprom_Read(_addr + 2))-48;
DD = (100*AA) + (10*BB) + CC;
IntToStr(DD, EE);
ptr = EE ;
while (*ptr == ' ') *ptr++;
// LCD_Out(1, 10, ptr);
// return(ptr);
return(DD);
}

// ********************* M A I N ****************************************

void main(){
Keypad_Init(); // Initialize Keypad
Lcd_Init(); // Initialize Lcd
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
// Label di inizio
Lcd_Out(1,3,"SMD OVEN v.1.0");
Lcd_Out(2,9,"by");
Lcd_Out(3,3,"MACROTEC)");
Lcd_Out(4,16,"2012");
Delay_ms(5000);
Lcd_Cmd(_LCD_CLEAR); // Clear display

// ================== KEYBOARD ===============
/* Premendo la sequenza "A" , "1" e "#", sebbene nella EEPROM
non cia scritto niente, si vede il caos nei messaggi sul display
*/
flag_function = 0;
PORTC = 0;
TRISC = 0;
ADCON1 = 0x0F; // Configure AN pins as digital I/O
cnt = 0;
lun = 0; // Reset counter

do {
kp = 0; // Reset key code variable
do
kp = Keypad_Key_Click(); // Store key code in kp variable
while (!kp);

switch (kp) {
case 1: kp = 49; break; // 1
case 2: kp = 50; break; // 2
case 3: kp = 51; break; // 3
case 4: kp = 65; flag_function = 1; // A
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "'A' Solder Curve ");
Lcd_Out(2, 1, "Select one of 5 step");
break;

case 5: kp = 52; break; // 4
case 6: kp = 53; break; // 5
case 7: kp = 54; break; // 6
//case 8: kp = 66; flag_function = 2; break;// B
//case 8: kp = 66; break; // B
case 9: kp = 55; break; // 7
case 10: kp = 56; break; // 8
case 11: kp = 57; break; // 9
case 12: kp = 67; break; // C
//case 12: kp = 67; flag_function = 3; break;// C
case 13: kp = 42; break; // *
case 14: kp = 48; break; // 0
case 15: kp = 35; break; // #
//case 16: kp = 68; flag_function = 4; break;// D
}
if (flag_function == 6){
do {
do
kp2 = Keypad_Key_Click(); // Store key code in kp variable
while (!kp2);
countkey++ ;
if (countkey <= 3) { // Che sia inferiore ella dimensione massima
if (countkey == 1) nn = kp2; // Se è il primo numero
if (countkey == 2) nn = nn*10 + kp2;
if (countkey == 3) nn = nn*10 + kp2;
IntToStr(nn, nr);
Lcd_Out(2, 4, nr);
}
} while (1);
}

if (flag_function == 1){

if (kp == 49 & flag_function == 1) { // 1
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Default Curve #1");
Lcd_Out(2, 1, "seconds : #");
Lcd_Out(3, 1, "temper. : *");
Lcd_Out(4, 1, "# or * for change");


AA = LeggiDati(0x000, 1);
Lcd_Out(2, 11, AA);
BB = LeggiDati(0x010, 1);
Lcd_Out(3, 11, BB);
}
//flag_function = 0;
if (kp == 35) { // # pressed Cambio secondi 0x000
flag_function =6; //
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2, 1, "Old time: sec.");
Lcd_Out(2, 11, LeggiDati(0x000, 1));
Lcd_Out(3, 1, "New time: sec.");
}

}

if (kp == 50) {
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Curva 2");
}
if (kp == 51) {
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Curva 3");
}
if (kp == 52) {
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Curva 4");
}
if (kp == 53) {
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Curva 5");
}

//}

} while (1);
}

// Generatore impusi di gate1 e gate 2 ---> OK Testato con PIC16F877 !!
/*
int pwr_low = 7; // Potenza resistenze inferiori da 0 a 9
int pwr_high = 7; // Potenza resistenze superiori da 0 a 9
int pwr;

void Delay_us();
void Vdelay_ms();

void impulso(){
Delay_us (100); // Durata dell'impulso di gate Triac
}


void interrupt(){ // Interrupt rutine
if(INTCON.INTF == 1 ){
if(pwr_low > pwr_high){
VDelay_ms (pwr_high); // Ritardo tempo minore
RE0_bit = 0xf; // Start Impulso di Gate RE0
impulso(); // Durata dell'impulso;
RE0_bit = 0x0; // End Impulso di Gate RE0
pwr = pwr_low - pwr_high; // Calcolo tempo rimanente
VDelay_ms (pwr); //ritardo dal tempo precedente
RE1_bit = 0xf; // Start Impulso di Gate RE1
impulso(); // Durata dell'impulso;
RE1_bit = 0x0; // End Impulso di Gate RE1
}
if(pwr_high > pwr_low){
VDelay_ms (pwr_low); // Ritardo tempo minore
RE1_bit = 0xf; // Start Impulso di Gate RE1
impulso(); // Durata dell'impulso;
RE1_bit = 0x0; // End Ipulso di Gate RE1
pwr = pwr_high - pwr_low; // Calcolo tempo rimanente
VDelay_ms (pwr); //ritardo dal tempo precedente
RE0_bit = 0xf; // Start Impulso di Gate RE0
impulso(); // Durata dell'impulso;
RE0_bit = 0x0; // Start Impulso di Gate RE0
}
if(pwr_high == pwr_low){
VDelay_ms (pwr_high); // Ritardo tempi identici
RE0_bit = 0xf; // Start Impulso di Gate RE0
RE1_bit = 0xf; // Start Impulso di Gate RE1
impulso(); // Durata dell'impulso;
RE0_bit = 0x0; // End Impulso di Gate RE0
RE1_bit = 0x0; // End Impulso di Gate RE1
}
INTCON.INTF = 0; // Clear Interrupt Flag
}
}
*/

robymak
Posts: 47
Joined: 08 Apr 2012 19:41

Re: [newbie] Help! Strange messages

#4 Post by robymak » 18 Apr 2012 13:11

:cry: :cry: "Il morto, interrogato, non rispose..." (cfr. Totò) :cry: :cry:

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: [newbie] Help! Strange messages

#5 Post by zristic » 18 Apr 2012 13:55

robymak wrote:"Il morto, interrogato, non rispose..." (cfr. Totò)
Che?

Post Reply

Return to “mikroC General”