PIC32 accessing xLCDQueue from other modules

randers wrote on Sunday, January 18, 2009:

in order to send msg’s to the LCD from other modules, I made the following changes to demo code

// main.c :
//static xQueueHandle xLCDQueue;
extern xQueueHandle xLCDQueue;

// main.c :
// xLCDQueue = xStartLCDTask();
/* xLCDQueue = */ xStartLCDTask();

and I intended to put the following code to other module (e.g. comtest.c):

extern xQueueHandle xLCDQueue;
static portCHAR sLCDBuffer[17];
static xLCDMessage xLCDMsg = { 500 / portTICK_RATE_MS, sLCDBuffer };
    xLCDMsg.pcMessage = "TX…";
    xQueueSend( xLCDQueue, &xLCDMsg, 0);

So in all cases the xLCDQueue defined in lcd.c should be used (instead of
the static copy in main.c, which is not accessible from other modules).

This seemed to work.
My intention is, to show (some of the) transmitted characters on the LCD.
So I additionally lowered the frequency of transmission by
#define comTX_MIN_BLOCK_TIME   ((portTickType)(1500 / portTICK_RATE_MS))
to have a chance to see the characters on LCD.
(Note: Making it too low causes “COM errors” - that’s OK)

But there is a certain behavior:  It often happens, that the LCD-lines are not
swapped and the first character is missing.
For example there is "ass 9" instead of "Pass 9".

Note: This happens already with a large comTX_MIN_BLOCK_TIME and without
          queuing from other tasks.

what do I wrong?

edwards3 wrote on Sunday, January 18, 2009:

There is nothing wrong with the way you are accessing the queue handle. I suspect the problem is how the characters are written to the lcd. Could they be wrapping around?

randers wrote on Sunday, January 18, 2009:

I just took an original v.5.0.3-demo and made my described modifications.
And sorry, I can not reproduce my troubles.
I come back, as soon as I can give a reproduceable description…

randers wrote on Tuesday, January 20, 2009:

in the mean time I found a short reproduceable way:

- Take the PIC32-Demo
- Remove the Blocktime-Task from project (3 locations in main.c)
- set configTICK_RATE_HZ (in FreeRTOSConfig.h) to a lower value !

1. configTICK_RATE_HZ = 50
   - the LCD is updated every second (like in error cases), but with "Pass 1", "Pass2", …
   - the LCD line-switch does not work properly
   (If the BlockTime-Task was not  removed, their supervising fires errors)

2. configTICK_RATE_HZ = 20
   - "Error: Int queue" is shown permanent
   - but sometimes (very rarely) the "E" is missuing and You see "rror: Int queue"
   - the LCD line-switch does not work properly

3. configTICK_RATE_HZ = 100
   - the original demo seems to work
   - but queuing LCD-messages from the COM-Task (that’s my original intention)
     cause heavy problems:
     * the LCD line-switch does not work properly
     * the first character is lost very often.

For my intentions I do not need a tickrate of 1000 Hz. This is according to the documentation.
But at least the demo LCD-task should work properly at nearly all lower tickrates.