fypstudent
Newbie level 3
i have written a C code for my expression. but i am not sure if my MCU could run it or not...
can my MCU support to do this mathematic expression?
the C code goes like this...
void EQUA (void)
{
for (x=0; x<MAX; x++){
y1 = 214*expf(-powf(((x-120)/6),2.00));
y2 = 61*expf(-powf(((x-181)/17),2.00));
y3 = 48;
y4 = 24*expf(-powf(((x-86)/20),2.00));
y = y1+y2+y3+y4;
if (y>255)
y = 255;
A = (int)y;
P1 = A;
if (x>MAX)
x=0;
}
}
void T0DELAY(void)
{
TMOD=0x01;
TL0=0x70;
TH0=0xCC;
TR0=1;
while (TF0==0);
TR0=0;
TF0=0;
}
int main()
{
while (1){
EQUA();
T0DELAY();
}
}
some one please try it and let me know if P1 got the result or not.
cos the last time i check, P1 does not give me the correct result. it give me a constant '1'
if my MCU could not do it becos it's only 8 bit. what can i do to make it work? i mean with changing the MCU...
can my MCU support to do this mathematic expression?
the C code goes like this...
void EQUA (void)
{
for (x=0; x<MAX; x++){
y1 = 214*expf(-powf(((x-120)/6),2.00));
y2 = 61*expf(-powf(((x-181)/17),2.00));
y3 = 48;
y4 = 24*expf(-powf(((x-86)/20),2.00));
y = y1+y2+y3+y4;
if (y>255)
y = 255;
A = (int)y;
P1 = A;
if (x>MAX)
x=0;
}
}
void T0DELAY(void)
{
TMOD=0x01;
TL0=0x70;
TH0=0xCC;
TR0=1;
while (TF0==0);
TR0=0;
TF0=0;
}
int main()
{
while (1){
EQUA();
T0DELAY();
}
}
some one please try it and let me know if P1 got the result or not.
cos the last time i check, P1 does not give me the correct result. it give me a constant '1'
if my MCU could not do it becos it's only 8 bit. what can i do to make it work? i mean with changing the MCU...