So, what I am doing is I took an example code provided by davidtosenovajan on mpc5777c. I cant build that example project which I modified, so what I am doing is I opened a new project I wrote my code build the project and replaced the existing elf file with elf file I build.
Why I am doing this is use the trace32 for debugging purpose which the example code has. This method worked fine, like I wrote a blinking led (ie toggling the gpio) it worked fine. Second I set the external enable pin of the msr in e200 core by writing inline assembler
asm("wrteei 1");
This set the externalenable bit in msr too. I did this to check if the assembly code is working or not
The main problem is :
asm ("lis %r30, 0x02005000@h");
asm ("ori %r30, %r30, 0x02005000@l");
asm ("lwz %r31, 0x0(%r30)");
This code is provided by davidtosenovajan to enable user mode. Whenver I executing this code in trace32 Powerview the moment I stepping on the 1st instruction the code stop working it is taking me to the location 00000060(address) fnmadd f31,f31,f31,f31 (mnemonic). I dont know why this is happening.
Even when I add value 1 to any register for example
asm("addi %r30,%r29,0x0001);
It is setting the register value to FFFFFFFF.
Previously I did some mini projects in arduino and 8051(keil) so I'm quite new to this, I explained it as much as I understood. So what should I do?
Regards,
M.V.S.I
Hello,
I am confused what you want to achieve. You modify the example code for what reason?
I see you want to modify to core registers. For that purpose you will use mt / mfspr instrucitons as described in core reference manual. Na not some reading of address of whatever.
Please refer to core reference manual e200z759n3CRM for operation with core registers:
https://www.nxp.com/webapp/Download?colCode=E200Z759N3CRM&location=null
Best regards,
Peter
Hi @petervlna ,
I am sorry for my explanation. The reason I want to modify the example code is that the example code has t32 windows batch file where trace32 launches the internal_FLASH.elf file, so I want to change the example code but it wouldn't build, so as I said I put my own elf file and renamed it as internal_FLASH this method worked fine.
regarding my question I changed my instructions into VLE format suprisingly it worked I entered user mode.This is the code
__asm__(" mfmsr %r23 ");
__asm__(" e_add16i %r24, %r23, 0x4000 ");
__asm__(" mtmsr %r24 ");
Now I got my second error
after entering user mode I used this code
__asm__(" mfmsr %r23 ");
__asm__(" e_add16i %r24, %r23, 0x4000 ");
__asm__(" mtmsr %r24 ");
vint32_t time = 0;
SIU.PCR[LEDPIN].R= 0x0200;
while(1){
while(time < 1000000)
{
SIU.GPDO[LEDPIN].R ^= 1;
time++;
}
time = 0;
}
This for gpdo toggling simple application but I am getting illegal instruction exception in ESR and bits MAV,ST,G,BUS_WRERR in MCSR are set I dont know why this happening
Sorry for being blunt if you still dont understand what I am doing keep that aside, I dont why the above exception happening so what should I do. Also I am attaching the mmu config just in case you need it.
Regards
M.V.S.I
Hello,
Since the content of r23 and r24 is unknown to me I guess this will require some debugging are reading of restricitons on MSR operation in core reference manual.
Also reading of exception and syndrome registers, will give you an idea where is the issue.
Best regards,
Peter
Thank you @petervlna . I'll look into it.