Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   "Code Error" with RegisterRepeatingTimer (http://www.chiefdelphi.com/forums/showthread.php?t=64505)

d235j 18-02-2008 20:03

"Code Error" with RegisterRepeatingTimer
 
We have tried using the sample code provided here (replacing the IFI Vex headers with FRC controller headers).
However, this code triggers a code error on our RC.
Basically, the printf("_____________________\r\r"); line executes several times, then is interrupted for 3-5 seconds, then repeats, and IR input does nothing at all. After a few repetitions, the CODE ERROR light comes on. (This is all in autonomous mode).

After commenting out EVERYTHING inside the CheckIR function (leaving only void CheckIR(void) { } ), and commenting out the IR processing code (but leaving printf("_____________________\r\r"); inside the while loop) ), this problem still happens.

We are using the latest version of WPILib on a 2008 RC. Also, there are no compile-time warnings or errors.

BradAMiller 19-02-2008 02:48

Re: "Code Error" with RegisterRepeatingTimer
 
You don't want to be printing from within the CheckIR function. Since that is an interrupt service routine, there might be problems doing long operations like that. I could imagine printing causing the code error to occur. Otherwise, I'm not sure what is going on without more information.

Also, there were a few problems with the whole program that some people were able to find and correct so be sure to read all the comments in the thread.

d235j 19-02-2008 16:48

Re: "Code Error" with RegisterRepeatingTimer
 
Quote:

Originally Posted by BradAMiller (Post 702145)
You don't want to be printing from within the CheckIR function. Since that is an interrupt service routine, there might be problems doing long operations like that. I could imagine printing causing the code error to occur. Otherwise, I'm not sure what is going on without more information.

This is how our program looks:

Quote:

#include "BuiltIns.h"
#include "API.h"
#include "ifi_aliases.h"
#include "user_defs.h"
#include <p18cxxx.h>

void CheckIR(void)
{
// empty
}

void main(void)
{
RegisterRepeatingTimer(30, CheckIR);
while(1)
{
printf("TestRun\r\r");
}
}
As far as I know, the printf function isn't being called within the CheckIR loop. The printf output comes in "bursts," and the RC locks up after a few loops.
Quote:

Originally Posted by BradAMiller (Post 702145)
Also, there were a few problems with the whole program that some people were able to find and correct so be sure to read all the comments in the thread.

I am aware of those corrections; however, those don't seem to be related to our problem.
Thank you.

d235j 22-02-2008 13:38

Re: "Code Error" with RegisterRepeatingTimer
 
I have partially resolved this problem. It only happens when "Code Model" under "Memory Model" under MPLAB C18 compiler options is set to "Large Code Model (>64K)".
Is this expected behavior?

sfs 27-02-2008 21:51

Re: "Code Error" with RegisterRepeatingTimer
 
Quote:

Originally Posted by d235j (Post 705074)
I have partially resolved this problem. It only happens when "Code Model" under "Memory Model" under MPLAB C18 compiler options is set to "Large Code Model (>64K)".
Is this expected behavior?

This sounds very familiar. We were having repeated problems (I don't recall the specifics now) using the Camera-related functions in WPILIB. After lots of frustration, we tried switching the memory model from large to small. Doing so suddenly resolved the problems we were having!


All times are GMT -5. The time now is 14:08.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi