2016-12-22 09:10 AM
Hello,
I work on a STM32F4 and I want use the CCM memory to declare my structures.
For example I want this kind of structure to be always declared in the CCM memory:
typedef struct Assign_Pot Assign_Pot;
struct Assign_Pot {
uint8_t variable1; uint8_t variable2; uint16_t variable3; };Assign_Pot* Assign_Tab[100];
I've been looking across the forum but I can't find a solution that works.
If I declare my structure like this:
struct Assign_Pot {
uint8_t variable1; uint8_t variable2; uint16_t variable3; } __attribute__ ((section('.ccm')));I have the warning: 'section' attribute does not apply to types [-Wattributes]
And the structure is not created in the CCM
Do you have some experience to share with this problem?
Thanks a lot, have a great day!
Note: this post was migrated and contained many threaded conversations, some content may be missing.2016-12-23 08:43 AM
Ok, but that is an array of pointers, not the data struct itself. You can't apply the attribute to the struct definition/typedef, just the static allocation.
How are you allocating the addresses you are stuffing in the pointers? malloc()?
You'd need to put the heap into the CCM for the allocator to pull from there, or modify the allocator to pull from multiple memory arenas.
typedef struct _Assign_Pot {
uint8_t variable1;
uint8_t variable2;
uint16_t variable3;
} Assign_Pot;
Assign_Pot Assign_Element[1000] __attribute__ ((section('.ccm')));
Assign_Pot* Assign_Tab[100] __attribute__ ((section('.ccm')));
Assign_Tab[12] = &Assign_Element[123];�?�?�?�?�?�?�?�?�?�?�?
2016-12-23 10:09 AM
I do not use any malloc, I just declare a table of structures as aglobal variable:
Assign_Pot* Assign_Tab[100];
This declaration should create a hundred of myAssign_Pot structure in .data, isn't it?
Sorry, I do not understand yourcode:
Assign_Pot Assign_Element[1000] __attribute__ ((section('.ccm')));
Assign_Pot* Assign_Tab[100] __attribute__ ((section('.ccm')));
Assign_Tab[12] = &Assign_Element[123];
2016-12-23 10:13 AM
This declaration should create a hundred of myAssign_Pot structure in .data, isn't it?
No, I'd expect it to allocate 100 32-bit pointers. What does sizeof() suggest? ** Put a larger 'int buffer[16]' in the structure to make it clearly apparent.
My code allocates 1000 structures, and 100 pointers, and then assigns one of the pointers with the physical address of one of the structures.