Robby
2010-01-15 18:22:06 UTC
Hello,
Today I ported a small function which values used to display fine in the old
compiler's watch window but now displays weirdly in the watch windows of
MPLAB/C32 and VC++ compilers.
In the last week, I have externed many int variables/arrays and char
variables the way it was instructed to me and up to now they all work fine. I
don't know if this has to do with the fact that externs for *char arrays* are
as valid as for the externs we do for ints and chars.
Basically, I am trying to innitialize a char array with 88 values. They are
simple byte values which have no relation to the ascii charaters. Please view
the small sippet of code:
Please see questions after this code:
=========================main.c
#include <stdio.h>
#include "setup.h"
#include "spi.h" // extern included so to be in scope of this file!
int main()
{
innit_buff();
set_spi_flash_buffer(spiFLASH_BUFFER);
return 0;
}
=======================setup.h
#ifndef SETUP_H
#define SETUP_H
void innit_buff();
#endif // SETUP_H //
=====================setup.c
#include "setup.h"
#include "spi.h"
void innit_buff()
{
int i=0;
// RESET FLASH BUFFER
for(i=0; i<88; i++)
spiFLASH_BUFFER[88] = 97; // <<< buffer assignment!
i = 0; /// BREAKPOINT #1
}
=======================spi.h
#ifndef SPI_H
#define SPI_H
extern unsigned char spiFLASH_BUFFER[88]; // buffer externed in a header
file
void set_spi_flash_buffer(spiFLASH_BUFFER);
#endif // SPI_H //
=======================spi.c
#include "spi.h"
unsigned char spiFLASH_BUFFER[88]; // extern declared in exactly one .c file!
void set_spi_flash_buffer(unsigned char spiFLASH_BUFFER[])
{
int r=0;
for(r=0;r<44;r++)
spiFLASH_BUFFER[r]= 0;
for(r=44;r<88;r++)
spiFLASH_BUFFER[r]= 255;
r=0; // <<< BREAKPOINT #2
}
=================================
QUESTION #1:
When the program hits BREAKPOINT #1, the "buffer assignment" line of code
(in setup.c) assigns to the buffer the value of 97. However, in the watch
window, the values of the "spiFLASH_BUFFER[88]" char array are always "0"
???? and it is displayed in the watch window this way:
spiFLASH_BUFFER 0x00e953c0
[0] ....0
[1] ....0
[2] ....0
[3] ....0
[4] ....0
...
...
[84] ....0
[85] ....0
[86] ....0
[87] ....0
I don't know why they are always 0 as opposed to bieng 97????
QUESTION #2:
When the program hits BREAKPOINT #2, the values of the
"spiFLASH_BUFFER[88]" char array are not even displayed anymore in the watch
window ??? All I see in the watch window now is a small blue cube and 0 as
its value, like this:
spiFLASH_BUFFER 0x00e953c0
[] ....0
I am wondering why I am not seeing every char value in this array this way:
spiFLASH_BUFFER 0x00e953c0
[0] ....0
[1] ....0
[2] ....0
[3] ....0
[4] ....0
...
...
[84] ....255
[85] ....255
[86] ....255
[87] ....255
Even though I am assigning regular numeric values to a char type array, we
should still be able to see them in the watch window... no?
confused!
Can anyone explain to me as to why we are seeing this type of information in
the watch window?
Thankyou all for your help.
Today I ported a small function which values used to display fine in the old
compiler's watch window but now displays weirdly in the watch windows of
MPLAB/C32 and VC++ compilers.
In the last week, I have externed many int variables/arrays and char
variables the way it was instructed to me and up to now they all work fine. I
don't know if this has to do with the fact that externs for *char arrays* are
as valid as for the externs we do for ints and chars.
Basically, I am trying to innitialize a char array with 88 values. They are
simple byte values which have no relation to the ascii charaters. Please view
the small sippet of code:
Please see questions after this code:
=========================main.c
#include <stdio.h>
#include "setup.h"
#include "spi.h" // extern included so to be in scope of this file!
int main()
{
innit_buff();
set_spi_flash_buffer(spiFLASH_BUFFER);
return 0;
}
=======================setup.h
#ifndef SETUP_H
#define SETUP_H
void innit_buff();
#endif // SETUP_H //
=====================setup.c
#include "setup.h"
#include "spi.h"
void innit_buff()
{
int i=0;
// RESET FLASH BUFFER
for(i=0; i<88; i++)
spiFLASH_BUFFER[88] = 97; // <<< buffer assignment!
i = 0; /// BREAKPOINT #1
}
=======================spi.h
#ifndef SPI_H
#define SPI_H
extern unsigned char spiFLASH_BUFFER[88]; // buffer externed in a header
file
void set_spi_flash_buffer(spiFLASH_BUFFER);
#endif // SPI_H //
=======================spi.c
#include "spi.h"
unsigned char spiFLASH_BUFFER[88]; // extern declared in exactly one .c file!
void set_spi_flash_buffer(unsigned char spiFLASH_BUFFER[])
{
int r=0;
for(r=0;r<44;r++)
spiFLASH_BUFFER[r]= 0;
for(r=44;r<88;r++)
spiFLASH_BUFFER[r]= 255;
r=0; // <<< BREAKPOINT #2
}
=================================
QUESTION #1:
When the program hits BREAKPOINT #1, the "buffer assignment" line of code
(in setup.c) assigns to the buffer the value of 97. However, in the watch
window, the values of the "spiFLASH_BUFFER[88]" char array are always "0"
???? and it is displayed in the watch window this way:
spiFLASH_BUFFER 0x00e953c0
[0] ....0
[1] ....0
[2] ....0
[3] ....0
[4] ....0
...
...
[84] ....0
[85] ....0
[86] ....0
[87] ....0
I don't know why they are always 0 as opposed to bieng 97????
QUESTION #2:
When the program hits BREAKPOINT #2, the values of the
"spiFLASH_BUFFER[88]" char array are not even displayed anymore in the watch
window ??? All I see in the watch window now is a small blue cube and 0 as
its value, like this:
spiFLASH_BUFFER 0x00e953c0
[] ....0
I am wondering why I am not seeing every char value in this array this way:
spiFLASH_BUFFER 0x00e953c0
[0] ....0
[1] ....0
[2] ....0
[3] ....0
[4] ....0
...
...
[84] ....255
[85] ....255
[86] ....255
[87] ....255
Even though I am assigning regular numeric values to a char type array, we
should still be able to see them in the watch window... no?
confused!
Can anyone explain to me as to why we are seeing this type of information in
the watch window?
Thankyou all for your help.
--
Best regards
Roberto
Best regards
Roberto