Debug of nested C structure

Discussion on both general simulation and Proteus VSM microcontroller simulation.
Post Reply
picchiedi
Professional User
Posts: 142
Joined: Thu 2014-12-25 9:32

Debug of nested C structure

Post by picchiedi »

Hello.
The enclose simple code, that uses nested C structure, fills an array with 0xFF values.
When I debug, looking at the real time array values update, I have following indication:
Format (-1) not valid for type (0x00000000).

Code: Select all

/* Main.c file generated by New Project wizard
 *
 * Created:   dom mag 30 2021
 * Processor: PIC18F452
 * Compiler:  HI-TECH C for PIC18
 */

#include <htc.h>

#define  ON   1 
#define  OFF   0 
 
#define  YVAL 64 // DEFINE 64 LINES 
#define  XVAL 8 // DEFINE 8X16=128 COLUMN

typedef union {
    int word;
    char nbyte[2];
} Dots;

typedef struct {
      Dots pix[YVAL][XVAL];
} GD_RAM;

GD_RAM gdram;

void glcd_fillScreen(char color) {
    char v, h;
    int d;
  
	   d = (color == ON ? 0xFFFF : 0x0000);
 
    for (v = 0; v < YVAL; v++) {
        for (h = 0; h < XVAL; h++) {
            gdram.pix[v][h].word = d;
            __delay_us(10);                                                                     //
        }
    }
 }

void main(void)
 { 
		glcd_fillScreen(ON);
		while (1)
      ;
 }


Thanks for any kind suggestion.

Regards
Attachments
Format not valid in debug.JPG
Format not valid in debug.JPG (203.47 KiB) Viewed 2513 times
Structure debug text.zip
(14.57 KiB) Downloaded 123 times
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Debug of nested C structure

Post by Ettore »

I think it's the union which makes debugger unable to define a valid data type (word ?, ascii text ?).
You can always force manually a data type if you click right on that highlighted line and select Hexadecimal.
Unfortunately you need to do that for any array element. Also, those manual settings are NOT persistent when you stop and re-run the simulation.
Kind regards,
Ettore Arena - Labcenter Electronics.
picchiedi
Professional User
Posts: 142
Joined: Thu 2014-12-25 9:32

Re: Debug of nested C structure

Post by picchiedi »

Thanks a lot, Ettore.
I did it, and you are right, but what I found strange is that all array elements are updated at the same time, and not one by one, as the "for cycles" procede.
However it is not crucial, since I can see the proper update in the RAM window...

Regards
Post Reply