View unanswered posts | View active topics It is currently Thu Sep 18, 2014 10:18 pm






Reply to topic  [ 4 posts ] 
hogCPU() crashes NXT 
Author Message
Rookie

Joined: Sun Oct 28, 2007 10:28 am
Posts: 4
Post hogCPU() crashes NXT
I'm trying to use hogCPU() to prevent two tasks writing to the same variable, but every time I call it my NXT hangs completely and I need to remove the battery to get it back again. I've included some sample code that illustrates the bug - not very useful code but it shows what I mean. I've tried using releaseCPU(), abortTimeslice() and EndTimeSlice() (which all seem to be the same thing) but no joy. Any ideas?

If you are going to try the code, link over your USB cable or you will descend into Bluetooth hell. :twisted:

Gordon

Code:
int tone;

task beeper()
{
   while (true)
   {
      PlayTone(tone, 1);
   }
}

task main()
{
   tone = 440;
   StartTask(beeper);
   while (true) {
      nxtDisplayTextLine(0, "Before ...");
      wait1Msec(1000);
      hogCPU();
      tone = 880;
      releaseCPU();
      nxtDisplayTextLine(0, "After ...");
      wait1Msec(1000);
      hogCPU();
      tone = 440;
      releaseCPU();
   }
}


Mon Nov 05, 2007 8:29 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post 
For a quick fix, try changing the intrinsic definitions in the file robotCIntrinsic.c to

intrinsic void hogCPU() asm(opcdSystemFunctions, byte(sysFuncHogProcessor));
intrinsic void releaseCPU() asm(opcdSystemFunctions, byte(sysFuncFreeProcessor));
intrinsic void abortTimeslice() asm(opcdSystemFunctions, byte(sysFuncSwitchContext));

The current definitions somehow got the "sysFuncXXXX" constants garbled.


Wed Nov 14, 2007 2:04 pm
Profile
Expert
User avatar

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
Post Datalogging symptoms
1. When using datalog NXT occasionally freezes the brick (completely, i.e. only battery power cycle helps). It seems as if the presence of Createdatalog() would increase the probability of the crash however I have not made too many attempts.

2. The datalog itself (comma separated values) contain two columns, of which the first is mostly constant and the second column contains the information I have intended to save.

3. It seems to me there's a new function called AddToDatalogEnhanced, quite poorly documented.


Thu Nov 15, 2007 7:17 am
Profile
Expert
User avatar

Joined: Fri Nov 09, 2007 4:51 am
Posts: 121
Location: Hungary, Europe
Post bugtrace
I've added a few entries to the bugtrace regarding to Release 1.10.


Fri Nov 16, 2007 7:59 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.