trouble in Demo/CodeWarrior_HCS12_banked

imajeff wrote on Friday, February 17, 2006:

Did the CodeWarrior/HCS12 Demo ever work? I don’t see how possible.

I have been using experimental ports for GCC/HCS12 for my own stuff, and now I’m getting serious about finishing the full Demo “HCS12_GCC_banked”. It is derived from the official “HCS12_CodeWarrior_banked”.

It was hard getting started with a normal debuger, but I’ve finally found the first problem why my demo is crashing when I vAltStartComTestTasks. In “Demo/Common/comtest.c” the demos use this global:
static xComPortHandle xPort = NULL;

The problem seems to be that xSerialPortInitMinimal() returns NULL, and even if it did return the xComPortHandle as was probably intended, the global xPort is never initialized! Somebody please let me know if you have got this demo to work in CodeWarrior.

I don’t have a CW setup, but I am going to try to resolve the bug to get my GCC/HCS12 demo working. I’ll drop a line when it works.

FreeRTOS V3.2.3
gcc version 3.0.4 m68hc1x-20030430 (that is m68hc1x patch release 3.0.1)

nobody wrote on Friday, February 17, 2006:

The demo serial port driver only supports one port.  The API is generic (used on all the ports) so the port number is passed in and out of the API functions but NEVER used - the COM port used is hard coded and created/initialised using the ‘processor expert’ addon to CodeWarrior not directly in the code. 

Therefore it is not intended that it gets used, and does not matter that it is not initialised.  It is only there as something has to be passed into the function.

imajeff wrote on Saturday, February 18, 2006:

Hello Mr. Nobody, thanks for responding to my probably-mistaken question.

I know it only supports one port, I couldn’t miss that when I’m this deep into development :wink:
but are you trying to imply (without saying) that you have actually seen the code work? It’s just hard to follow when I know it’s not working.

Don’t worry, I’ll probably catch what I missed about xPort not being used, after I sleep a little. It’s funny. I have a full application working which uses both serial ports on the MCU. That was one of the very things… I rewrote some stuff including using the xComPortHandle because I had to keep track. I probably knew back then how this demo really worked.

At least I’ve got that full app working. A transmitter sends wireless data and the FreeRTOS app reads it from one serial port, processes control code, and sends motor control to the second serial port to drive all the motors. It’s cool, but I just haven’t gotten my stupid Demo to work which doesn’t have to do anything useful. Strange, huh?

rtel wrote on Saturday, February 18, 2006:

The demo applications are left on soak test for a week or so before they make it into the download, so yes, it has run before.  It was built with Codewarrior tools, not GCC.

Sound like you have a nice application running which is more complex than the demo, which may be a clue.

The demo applications normally squeeze in as much as possible into the given ROM and RAM.  Could it be that GCC is using more stack and therefore this is causing problems?

imajeff wrote on Monday, February 20, 2006:

– Richard said –
"Sound like you have a nice application running which is more complex than the demo, which may be a clue."

Precisely why I was wrong :-/  My application had required that handle to be used because it uses two COM ports. So the clues are throwing me off.

Stack seems likely, although I added 16 to the minimum and that didn’t solve it. I’ll try something huge if I still have the ram, but the problem might also be some small thing I added when taking out some CW stuff. That extra CW overhead sure looks big and silly when you see it outside of Processor Expert, in a simple example.

Thanks, I’ll post when I solve this.

imajeff wrote on Tuesday, February 21, 2006:

Oh, I think I got it.

Before, I thought I could guess how much the configMINIMAL_STACK_SIZE would need to increase, and then do a little more. Instead, apparently I should make the stack sizes obsessively huge at first, because now it is running!

I think next I’ll look at a bunch of the stacks to see how oversized. I increased minimal size from 80 to 120. Maybe that’s not so bad but I try to be overly conservative :)  I’m just releived the demo seems to be fully working now.

When I clean this up, I’ll send the demo to Richard so hopefully he can add official support for GCC/HCS12.

I’ve also got a little documentation to write on this demo so people will know how to config things to their environment.

Thanks everyone helping with this port.  --jeffs

nobody wrote on Tuesday, February 21, 2006:

The only place that configMINIMAL_STACK_SIZE  is used in the kernel code itself [rather than the demo application code] is setting the size of the idle task stack.  Each other task can use different size if best.

imajeff wrote on Friday, February 24, 2006:

Right, meaning the Demo crashed because the configMINIMAL_STACK_SIZE was too small. In my application, I don’t need as much stack as the demo tasks. It looks like the Integer math task was overflowing. It takes more stack than I anticipated for temporary storage while doing the math expressions.

I guess GCC was designed to use more registers, I turned off softregs (i.e. _.d1, _.d1), and so it quitely allocates temp stack space for it.