Reading from address where const is declared

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Ana0211
Level 2
Level 2
10 likes given 5 replies posted 5 likes given

Hello,

I am currently trying to place some data at a precise address, that can be later on modified by erasing and writing the flash. After that, I would like to read the data.

I place my data like so:

const volatile uint8 data __at(0x80400000) = (uint8)0x00;

After erasing the flash and writing some other value, I can see the new value in the memory watch during debug. However, when I read it through a variable, I always get the old value.

I am using volatile on all variables that are concerned and I also tried reading through memcpy function. I am currently using Aurix Developement Studio and I deactivated all optimization on the code (as far as I know).

 

Is there any particular way to read this new data ?

Thank you !

0 Likes
1 Solution
cwunder
Employee
Employee
100 solutions authored 5 likes given 50 likes received

Do you have the cache enabled? If you read it from segment 0xA what happens?

View solution in original post

3 Replies
cwunder
Employee
Employee
100 solutions authored 5 likes given 50 likes received

Do you have the cache enabled? If you read it from segment 0xA what happens?

Ana0211
Level 2
Level 2
10 likes given 5 replies posted 5 likes given

Hi,

Apparently, reading from the segment 0xA solves my problem. However, IFX_CFG_SSW_ENABLE_TRICORE1_PCACHE is defined, so I guess the cache should be enabled. Do you have any idea why I have this behaviour ?

Thank you!

0 Likes
Yuva
Moderator
Moderator
Moderator
250 replies posted 250 sign-ins 100 solutions authored

Hello,

In your scenario, the old data is in the cache. When reading, the data is read from the cache and not from the main memory. You need to invalidate the cache after memory modification so that the new data is available in the cache.

Thanks

0 Likes