Compiler problem or my problem?

General discussion on mikroC.
Post Reply
Author
Message
sionix
Posts: 7
Joined: 07 Apr 2005 01:08

Compiler problem or my problem?

#1 Post by sionix » 26 May 2005 17:37

Hello and please help me!
I'm doing a soccer robot to participate on Robocup 2005 on Osaka.
My problem if is I make a great number of sucessive calls to functions, the program starts to become "crazy". I have a function called read_sensors, and when I put more than ... calls to other functions (see example bellow) then my program simply do not work. The more strange is that afects not only the function read_sensors, but all the program, inclusive the main function were the function read_sensors...

PLEASE HELP ME!
someone know if is my problem or if that is a compiler problem ?

void read_sensors() {
I2C_Init(100000);
I2C_Start(); // issue I2C start signal
I2C_Wr(0xB0); // send byte via I2C (device address + W)
I2C_Wr(0); // send byte (data address)
I2C_Repeated_Start(); // issue I2C signal repeated start
I2C_Wr(0xB1); // send byte (device address + R)
sensor[0] = I2C_Rd(0u); // Read the data (acknowledge)
I2C_Stop();
Delay_ms(5);
I2C_Init(100000);
I2C_Start(); // issue I2C start signal
I2C_Wr(0xB0); // send byte via I2C (device address + W)
I2C_Wr(1); // send byte (data address)
I2C_Repeated_Start(); // issue I2C signal repeated start
I2C_Wr(0xB1); // send byte (device address + R)
sensor[1] = I2C_Rd(0u); // Read the data (acknowledge)
I2C_Stop();
Delay_ms(5);
I2C_Init(100000);
I2C_Start(); // issue I2C start signal
I2C_Wr(0xB0); // send byte via I2C (device address + W)
I2C_Wr(2); // send byte (data address)
I2C_Repeated_Start(); // issue I2C signal repeated start
I2C_Wr(0xB1); // send byte (device address + R)
sensor[2] = I2C_Rd(0u); // Read the data (acknowledge)
I2C_Stop();
Delay_ms(5);
I2C_Init(100000);
I2C_Start(); // issue I2C start signal
I2C_Wr(0xB0); // send byte via I2C (device address + W)
I2C_Wr(3); // send byte (data address)
I2C_Repeated_Start(); // issue I2C signal repeated start
I2C_Wr(0xB1); // send byte (device address + R)
sensor[3] = I2C_Rd(0u); // Read the data (acknowledge)
I2C_Stop();
Delay_ms(5);
I2C_Init(100000);
I2C_Start(); // issue I2C start signal
I2C_Wr(0xB0); // send byte via I2C (device address + W)
I2C_Wr(4); // send byte (data address)
I2C_Repeated_Start(); // issue I2C signal repeated start
I2C_Wr(0xB1); // send byte (device address + R)
sensor[4] = I2C_Rd(0u); // Read the data (acknowledge)
Delay_ms(5);
I2C_Init(100000);
I2C_Start(); // issue I2C start signal
I2C_Wr(0xB0); // send byte via I2C (device address + W)
I2C_Wr(5); // send byte (data address)
I2C_Repeated_Start(); // issue I2C signal repeated start
I2C_Wr(0xB1); // send byte (device address + R)
sensor[5] = I2C_Rd(0u); // Read the data (acknowledge)
I2C_Stop();
Delay_ms(5);
}


void i2c_motores(char ctrr, char spd){
I2C_Init(100000);
I2C_Start();
I2C_Wr(0xf0); // send byte via I2C (command to 24cO2)
I2C_Wr(ctrr);
I2C_Wr(spd); // send data (data to be written)
I2C_Stop();
}


regards
sionix @ Portugal

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#2 Post by LGR » 26 May 2005 18:14

You didn't state the PIC you are using, but 16F PICs only have an 8-deep stack, and 18F PICs have 32. If you have a lot of nested calls, particularly on a 16F, it'll crash.
If you know what you're doing, you're not learning anything.

sionix
Posts: 7
Joined: 07 Apr 2005 01:08

#3 Post by sionix » 26 May 2005 19:00

i'm using 18f458 ..... u think is that the problem ?
sionix @ Portugal

sionix
Posts: 7
Joined: 07 Apr 2005 01:08

#4 Post by sionix » 26 May 2005 19:00

i'm using 18f458 ..... u think is that the problem ?
sionix @ Portugal

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#5 Post by LGR » 26 May 2005 19:07

I don't think so. 18F allows 32 nested calls. You might want to try simulation, or examine the ASM.
If you know what you're doing, you're not learning anything.

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

Re: Compiler problem or my problem?

#6 Post by zristic » 26 May 2005 19:16

Please send us the .lst file of your project and we will examine it. I doubt it is the compiler, but let's give it a try.

You can find .lst file in the folder the .hex file is.

The email is: zristic@mikroe.com

sionix
Posts: 7
Joined: 07 Apr 2005 01:08

#7 Post by sionix » 26 May 2005 20:31

i've sent email yet ;-)
sionix @ Portugal

Jeff
Posts: 1
Joined: 04 Jun 2005 07:48
Location: Belgium

#8 Post by Jeff » 04 Jun 2005 07:58

Any news about this topic?

Many thanks in advance

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

#9 Post by zristic » 04 Jun 2005 08:17

Jeff wrote:Any news about this topic?
We examined .lst file, made some suggestions to sionix, but he never replied

Post Reply

Return to “mikroC General”