Evening,
We found some quite interesting problem regarding new S32 version.
We were working on S32 V1.1 for quite some time now and today we have switched on V1.2. Hardware we are working on is MPC5744P and problem emerged on our STM (System Timer Module) driver.
Problem is when it tries to set PRESCALER value program jumps to IVOR1 machine check. Digging deeper we found that when writing PRESCALER value to STM_0.CR.B.CPS register it tries to write value as BYTE and not as WORD which is of course triggering error because as said in MPC5744P Reference Manual STM registers can only be accessed using 32-bit (word) accesses.
As seen on picture above S32 Design Studio V1.1 is used and it writes value as word.
On picture above v1.2 is used and it can be seen that on same line of code it tries to write value as BYTE which results in MachineCheck IVOR1.
Problem can be solved by OR-ing value as: STM_0.CR.R |= STM->prescaler - 1;
but it is not readable as above solution.
Why is only prescaler value being written as BYTE and the rest are written as WORDs?
Regards,
Ivan
解決済! 解決策の投稿を見る。
Hi Ivan,
There is one change in the default compiler settings in v1.2.
Strict volatile bitfields are not forced anymore by default for e200zX cores
I'd recommend you to add this compiler flag to your project settings:
-fstrict-volatile-bitfields
Hope it helps.
Stan
Hi Ivan,
There is one change in the default compiler settings in v1.2.
Strict volatile bitfields are not forced anymore by default for e200zX cores
I'd recommend you to add this compiler flag to your project settings:
-fstrict-volatile-bitfields
Hope it helps.
Stan
It is working now. Jiri and Stanislav thank you for your help. I will mark Stanislav's answer as correct one.
Ivan
Hello Ivan,
I tried reproduce your issue - but when I'm using unsigned char and int - in both cases is code working for me and disassembly uses word instructions - even with -O3 optimization. How is defined your STM->prescaler variable?
Jiri
Hello,
We are using -O1 optimisation but have also tried it on -O3. Same machine check is happening in both cases. Below is attached picture with STM structure.
Are you sure you are using V1.2?
Ivan
I'm using v. 1.2 - build number 170217. With your structure, -O1 and this source code
I got this disassembly and STM_0.CNT is counting without any exception.
Do you have installed all updates? (main menu bar -> help -> check for updates) Wich language dialect are you using? (i left the section in default settings).
Jiri
I am using Version: 1.2 and Build id: 170613. S32 is up to date. Language dialect is left blank. Optimisation is also on -O1.
I tried your code and it still tries to write it as byte.
Ivan
I got the 170613 version (I had some pre-release version) - and you are right - output code is using byte instruction also with unsigned int as a variable for prescaler storage or with direct number. Thank you for catching this. I'll create JIRA ticket S32DS team.
As a temporary workaround - you can use OR or switch back to previous version. I'm not sure if this error is affecting other read/write operations with registers.
Jiri
Thank you for your feedback. We didn't get any strange behaviour from other drivers so hopefully its isolated case.
Ivan