Hi,
I develop KEAZ128 MCU with S32DS.When running to the code below(s==4,or2),the MCU stop running.
if (s==4) {
*(CCP_DWORD*)d = *(CCP_DWORD*)p;
} else if (s==2) {
*(CCP_WORD*)d = *(CCP_WORD*)p;
} else {
*d = *p;
}
But, if I change the code to below, it's running ok. I guess the problem it's the pointer.
But the same code running ok on S32K144 MCU.
So, why?
CCP_BYTE i;
if (s==4) {
for(i = 0; i < 4; i++)
{
*d++ = *p++;
}
} else if (s==2) {
for(i = 0; i < 2; i++)
{
*d++ = *p++;
}
} else {
*d = *p;
}
Hi,
What's the value of d and p?
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi,
If you do not put these operation in wdog, do you meet this problem again?
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi,
I never put the operation in watchdog.
I just disable the interrupt with " __asm("CPSID i")" before the operation and enable the interrupt after the operation.
Whatever I will test the function again.
Hi,
I test the usage of pointer you provided on FRDM-k64. It works well. So I think it may be not the pointer problem. I can't reappear the problem. So it is hard to say what causes this result.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi,
I test the funtion again.I found when the code running to the two lines below it will get wrong.
00019e90: ldrh r0, [r0,#0]
00019e92: strh r0,[r2,#0]
Do you know why?
I seach on the internet,it said: maybe the pointer point to non aligned address will lead to hard err.Is the reason?
In my project.
CCP_BYTE dtm[8];
d = &dtm[1];
*(CCP_DWORD*)d = *(CCP_DWORD*)p;
Hi,
You can try to align your two variable. It looks like that the 'd' address is not aligned.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------