PDA

View Full Version : "Code Error" with RegisterRepeatingTimer


d235j
02-18-2008, 07:03 PM
We have tried using the sample code provided here (http://www.chiefdelphi.com/forums/showthread.php?t=61578) (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
02-19-2008, 01:48 AM
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
02-19-2008, 03:48 PM
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:


#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.

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
02-22-2008, 12:38 PM
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
02-27-2008, 08:51 PM
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!