No chance to see that! Use windows's calculator set to "programmer"-mode or assign the #defined value to a variable for inspection when debugging.
I changed then all to absulte values but will need to manually adjust them each time I change the size of an item.
Next problem is I cannot figure out the EEPROM. I am attempting to write some data to it and read back but I seem to get back all "0". I understand the functions are blocking but added delays for good measure during test. Data sheet says you can write after 5us of starting the component. I stop it after to ensure no accidental write. Below is my attempt to use the compopent after looking at datasheet and example.
unsigned char *dataptr;
dataptr = (unsigned char *) Settings+ i * EEPROM_ROWSIZE;
unsigned short i;
reg8 * ReadPtr;
ReadPtr = (reg8 *) CYDEV_EE_BASE;
for(i = 0u; i < NUM_SETTING_WORDS; i++)
Settings[i] = ReadPtr[i];
Based on write definition "i" wants to be uint8 -
EEPROM_Write(const uint8 * rowData, uint8 rowNumber)
Same thing for the data. Note char from one compiler to another not
necessarily same as uint8.
I think the function prototype should beEEPROM_Write(uint8 * rowData, uint8 rowNumber)whererowData is pointer to the array of 16bytes to be programmedie you load the array with data first then pass the pointer of the 1st byte to the function
EEPROM_Write(const uint8 * rowData, uint8 rowNumber)
Above taken from datasheet. PSOC 5LP. Below is GCC handling of
the const qualifier. Taken from GCC manual.
A Note On const
Many users bring up the idea of using C's keyword
constas a means of declaring data to be in Program Space. Doing this would be an abuse of the intended meaning of the
constis used to tell the compiler that the data is to be "read-only". It is used to help make it easier for the compiler to make certain transformations, or to help the compiler check for incorrect usage of those variables.
For example, the const keyword is commonly used in many functions as a modifier on the parameter type. This tells the compiler that the function will only use the parameter as read-only and will not modify the contents of the parameter variable.
constwas intended for uses such as this, not as a means to identify where the data should be stored. If it were used as a means to define data storage, then it loses its correct meaning (changes its semantics) in other situations such as in the function parameter example.
I copy mine from creator EEPROM data sheet.
My previous post is just to point out the issue with the write function that needs to get the values from an array, nothing to do with the "const".
I looked at datasheet, its "Document Number: 001 -85001 Rev. *B", shows a number
of revs to write functions. Creator 3.0 SP2.
Instead of #defines, try using typedef enum to set the values of your index pointers. These values should show up in your debug.
I didn't realise you could do calculated feilds inside an enum.
If I understand your intent, let me offer this:
var1 = &addr1 // address of some variable put into var1
var2 = &addr2 // etc.......
var3 = &addr3
So NUM_VARS gives the total number of variables which is 3. Now you can reference the addresses of your various arrays via var1, etc. Perhaps the var1, var2 and var4 could be elements of an array. I haven't tried the actual compile but give it a try and use your code.
Does this mean that just to see the calculated addresses I need to do this....
#define addr1 0
#define addr2 addr1 + 3
#define addr3 addr 2 + 17
And then set watch window on the enum values to see what the calculated addresses are?
I don't see why you would need the defines with offsets hard coded. The & symbol just puts the address of the array or string into var1, var2, and var 3. I'm not sure if you are using arrays or offsets into a particular string. If you are using various string names, this just sets up addresses to the first element of each string.
I haven't tried it, but perhaps var1 var2 var3 could be replaced with var, var, var. This would be an array containing the addresses of the arrays, variables, or strings you are trying to access. Don't take my word for it. Try it.
I'm not sure if I understand what you are trying to do but if the offsets are really the length of strings, you can use this code to determine the length of the string. It just searches the dereferenced pointer until it detects a null. The length of the string is reported in i. There's your string length to calculate the offset to the next string.
uint8 i = 0;
// i contains the length of the string.
I re-read your original post. It seems that the length of strings can change dynamically. You might have to declare a variable as volatile since the compiler will not have any knowledge of dynamic changes at run time.
Referring to my original post.
I wanted to view the calculated addresses of #define I had set up. These are starting addresses for reading various types of information from EEPROM.
I have an originating address and then all the other addresses are relative to it.
Later I may want to add new data structure or make for entries in existing structure and I don't want to have to calculated new positions all the time.
For instance, say one block was storing 5 phone numbers and I set the number of digits to 10, and the following block contained contact names
#define PHONE_NUMBERS 0
#define CONTACTS PHONE_NUMBERS + (NUM_PHONES * DIGITS)
This way I can change PHONE_NUMS or DIGITS and not need to recalculate any addresses. But, when I debug to determine whether right data is in correct location, the #define does not show me the actual value assigned of say "Contacts", but it WILL show me that PHONE_NUMBERS has value of "0". It does not seem to like to show a calculated value for define.
This si what my original post was talking about.