Plateau
Junior Member level 3
- Joined
- Jan 4, 2012
- Messages
- 30
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,288
- Activity points
- 1,553
HiHo, friends, are you all fine?
After so much problems in handling the interrupts, I've decided to use the KBHIT approach (https://www.edaboard.com/threads/277650/). Now, everything is ok but I have a doubt about dynamic memory use.
In my code, I have a pair of routines to write and read data from EEPROM. Both are based on native CCS EEPROM routines.
The read routine is:
I don't know why, but this routine only works well when I declare the variable 'TEXTO' as a static length array. When I use the dynamic array associated with calloc, the array TEXTO always returns with wrong length (per example, if the right length would be 10, it returns 12).
Can anybody help me to solve this issue?
Regards,
Pedro Rosa.
After so much problems in handling the interrupts, I've decided to use the KBHIT approach (https://www.edaboard.com/threads/277650/). Now, everything is ok but I have a doubt about dynamic memory use.
In my code, I have a pair of routines to write and read data from EEPROM. Both are based on native CCS EEPROM routines.
The read routine is:
Code:char* leStringEEPROM(int8 low, int8 high){ //char* texto = calloc((high-low),sizeof(char)); char texto[12]; int8 i,y=0; for(i=low;i<high;i++){ texto[y] = (char)read_int16_eeprom(i); y++; } return texto; }
I don't know why, but this routine only works well when I declare the variable 'TEXTO' as a static length array. When I use the dynamic array associated with calloc, the array TEXTO always returns with wrong length (per example, if the right length would be 10, it returns 12).
Can anybody help me to solve this issue?
Regards,
Pedro Rosa.