Hi Experts,
I am using MPC5748G where my issue is ; it’s sometimes got stuck some where in code hence making watchdog to reset the microcontroller.
To find root cause of above issue, mine objective is to send out certain CAN messages before watchdog reset our microcontroller.
That logic already has been implemented successfully by enabling watchdog interrupt and its ISR and it’s working normally.
Now I want to covert below written assembly language instructions into c language instructions and want to send out the content of these registers through CAN in watchdog interrupt ISR. Please let me know following things.
1 How I can convert these instructions into C language?
2 How to get access to these registers. What kind of statement I should write so that I can get access to these registers.
Regards
已解决! 转到解答。
Hi,
MSR is a core register, it's not memory mapped. The only way to access core registers is to use asm instructions. In C language, you can use macros like this:
#define MFMSR() ({unsigned int rval; __asm__ volatile("mfmsr %0" : "=r" (rval)); rval;})
#define MTMSR(v) __asm__ volatile("mtmsr %0" : : "r"(v))
And then use them in C code:
unsigned int temp;
temp = MFMSR(); //read MSR
MTMSR(temp); //write MSR
If you want to store the content in asm function (like in IVOR handler), you need to get address of C variable and store it to the variable using asm instructions.
Regards,
Lukas
Hi,
MSR is a core register, it's not memory mapped. The only way to access core registers is to use asm instructions. In C language, you can use macros like this:
#define MFMSR() ({unsigned int rval; __asm__ volatile("mfmsr %0" : "=r" (rval)); rval;})
#define MTMSR(v) __asm__ volatile("mtmsr %0" : : "r"(v))
And then use them in C code:
unsigned int temp;
temp = MFMSR(); //read MSR
MTMSR(temp); //write MSR
If you want to store the content in asm function (like in IVOR handler), you need to get address of C variable and store it to the variable using asm instructions.
Regards,
Lukas