Odd problems when running code

General discussion on mikroC PRO for PIC32.
Author
Message
brandonb
Posts: 105
Joined: 24 Jan 2013 03:24

Re: Odd problems when running code

#16 Post by brandonb » 30 Apr 2019 22:16

Quote:
you mentioned the aligned attribute... can someone explain how i should impliment that... suppose i have char U1rx_inbox[1024]; and i want that to be aligned as if it where and array of 256 Uint32's ?

You can use it in this way :
Code: Select all
unsigned long xyz[1024] aligned(32);

We have covered this in the help file, please check it out.
example was incorrect for what was asked... and where is this in the help file?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Odd problems when running code

#17 Post by filip » 03 May 2019 09:49

Hi,

Type Variable Attributes in the index search and the topic will open.

Regards,
Filip.

brandonb
Posts: 105
Joined: 24 Jan 2013 03:24

Re: Odd problems when running code

#18 Post by brandonb » 03 May 2019 15:38

Variable Attributes
The variable attributes aligned and packed are optional in declarations and do not actually affect the type of variable.

Attribute aligned
This attribute specifies a minimum alignment for the variable or structure field, measured in bytes. For example, the declaration :

int x aligned(16);

or alternative syntax :

int x __attribute__ ((aligned(16)));

This will cause the compiler to allocate the global variable x on a 16-byte boundary.
The aligned attribute can only increase the alignment, but you can decrease it by specifying packed as well.
why 16 and 32 BYTE boundaries. why not 4 byte boundary? starting to feel like i hijacked this post and getting the run around as punishment. its a simple thing really, when ever i create a char array i want to ensure its first element is located at a hex address that ends in ( 0,4,8,C ). if 16 and 32 byte boundaries are the correct way to do it could someone explain. at first impression it seems people pick aligned 16 and 32 thinking they are bits.

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: Odd problems when running code

#19 Post by pwdixon » 08 May 2019 15:42

Yep you've achieved exactly what the ME people wanted. You've moved the descussion onto something they can point to in their help file, it doesn't help you or me but at least they can say they've done their bit and provided answers on the forum.

Notice as well that even your question on bits/bytes as been left hanging, by the way I didn't think it sounded right either but I'm desperate and still haven't got a solution to my original problem.

Post Reply

Return to “mikroC PRO for PIC32 General”