Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] MikroC count_down timer error.Plesss help me!!

Status
Not open for further replies.

Alberto Dan

Junior Member level 3
Joined
Jun 5, 2014
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,584
Hy i have a problem with a count down timer.I m new in microcontroller,i stardet to learned two month ago.Now i try to make a countdouwn timer from 99 to 0.Next i want to try to maket from 9999 to 0.I don't understant what about interrupt and i try to make it only from C.
Now i write a code but in Mikroc Give me to error:
1)temp1 = (value%10); //error opeator is not applicable to these operands
2) value = chose_value(); //error not enought parameters
and i don't understand why
I did not succeed for now to try my code to see if it's work because of this error.If anybody want to watch in the code and give some ideas what think about it...
I atach a photo with proteus schematics.
Thx werry much ,i need a help please!!!

My code is:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
sbit en_enter at RA2_bit;
double temp1 =0;
double temp2 = 0;
 
 
///////////////////////////////Set PORTC output ////////////////////
 
 void toportc(int a)
{
switch(a)
{
         case 0:
              portc=63;
              break;
         case 1:
              portc=6;
              break;
         case 2:
              portc=91;
              break;
         case 3:
              portc=79;
              break;
         case 4:
              portc=102;
              break;
         case 5:
              portc=109;
              break;
         case 6:
              portc=125;
              break;
         case 7:
              portc=7;
              break;
         case 8:
              portc=255;
              break;
         case 9:
              portc=111;
              break;
         default:break;
         }
}
 
 
/////////////////////////////////////Show The Time Function//////////////////////////
void show_time(double value)
{
     porta.ra3=0;
     porta.ra4=1;
     temp1 =(value/10);
     toportc(temp1);
     delay_ms(200);
     portc=0;
     
     porta.ra3=1;
     porta.ra4=0;
     temp1 = (value%10); //error opeator is not applicable to these operands
     toportc(temp1);
     delay_ms(200);
     portc=0;
     
     }
 
 
////////////////////////////////Chose value Function/////////////////////////
double chose_value(double value)
{
 double value =0;
 char new_encoder,last_encoder;
 while(en_enter == 0)
 {
      new_encoder = (porta & 0x03 );
      if(new_encoder != last_encoder)
      {
                     if(new_encoder.F1 == last_encoder.F0)
                                       value+=0.25;
                     else
                                       value-=0.25;
      last_encoder = new_encoder;
      }
      if((value <0) || (value >= 100))
         value = 0;
      show_time(value);
      }
      return value;
      
/*
while(en_enter ==0)
{
       if(portb.rb4 == 1)
       {
                    value++;
                    delay_ms(300);
       }
       
       if(portb.rb5 == 1)
       {
                    value--;
                    delay_ms(300);
       }
       
       if(value == 100)
       value = 0;
 
       if(value <0)
       value =0;
       show_time(value);
      }
      return value;
*/
 
 
 }
 
 ///////////////////////////////////Count_Down Function//////////////////////////////////////////
 void count_down(int value)
 {
      int i=0;
      portb.f1 = 1;
      delay_ms(10);
      
      for(i=value ; i>=0 ; i--)
      {
                  show_time(i);
                  delay_ms(990);
      }
      delay_ms(10);
      portb.f1=0;
      
 }
 
//////////////////////////////////////Fumnctia MAIN//////////////////////////////////
void main() {
 
double value =0.0;
ADCON1 = 0b00000110;//all portA as digital I/O
TRISB = 0XFF;//SET PORT B AS IMPUT
TRISC = 0X00;//SET PORT C AS OUTPUT
 
for(;;)
{
       value = chose_value();  //error not enought parameters
       count_down(value);
}
 
}



This is my schematic on proteus


count down.PNG
 
Last edited by a moderator:

1) I assume that error is occurring in the 'show_time' function (line 59 above). In that function, 'value' is defined as a double and the modulus operator ('%') is not defined for doubles - only integer values.
2) The 'choose_value' function declaration contains a parameter (a double called 'value') and so any call to that function, such as the one you make in the 'main' function in line 144 must also provide a parameter.
These have nothing to do with your circuit or interrupts or timers etc. They are basic C programmign language errors.
Susan
 

Thx you verry much,i try when i go home.I hope works!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top