2016-06-30 04:43 AM
Hi everybody,
I'm trying to get my SPC560C05L3 into Standby mode, but it's not working. I also tried other modes, and getting the controller into every RUN mode is no problem, but the other modes just don't work. I use this bit of code:ME.MCTL.R = SPC5_ME_MCTL_MODE(STANDBY_MODE) | SPC5_ME_MCTL_KEY; ME.MCTL.R = SPC5_ME_MCTL_MODE(STANDBY_MODE) | SPC5_ME_MCTL_KEY_INV; if(ME.GS.B.S_MTRANS){ Send_CAN_message(); }but it's not working. I also don't get my CAN message and the processor just continues running the rest of the code. I already checked my wake-ups, and all wake-ups are disabled except 1, and that one doesn't have an active trigger and isn't triggered at all.Am I missing something to get the controller into standby mode?Thanks,Mitchel #spc560-mcu #standby2016-06-30 06:03 AM
Update: I changed some settings around, and when I try to go into STANDBY, the controller freezes. When stopping with the debugger, it shows that it is on the following line:
0x000000E0: 78 00 00 00 E_B _IVOR1 (0x000000E0)Anybody know how that can happen?2016-06-30 06:40 AM
2016-06-30 10:40 PM
Hi Erwan,
Thank you for reply. I'm using a SPC560C50L3. I updated my code because I though the same thing. I now have the following: WKUP.WISR.R = 0x200; // Status flag ME.IS.R = 5; ME.MCTL.R = SPC5_ME_MCTL_MODE(STANDBY_MODE) | SPC5_ME_MCTL_KEY; ME.MCTL.R = SPC5_ME_MCTL_MODE(STANDBY_MODE) | SPC5_ME_MCTL_KEY_INV;With this code, I can see with the debugger that it goes into standby mode, but I still see that it goes to the line I copied before:0x000000E0: 78 00 00 00 E_B _IVOR1 (0x000000E0)So what I can figure is that it does go into standby, but then freezes on that line. The only way to get the controller working again is with a power cycle.Regards,Mitchel2016-06-30 10:52 PM
Ok, another update:
I added a loop to the switch to standby (copied and modified from the SPC5 studio function SetRunMode) to check if the mode transition is ok. WKUP.WISR.R = 0x200; // Status flag ME.IS.R = 5; ME.MCTL.R = SPC5_ME_MCTL_MODE(STANDBY_MODE) | SPC5_ME_MCTL_KEY; ME.MCTL.R = SPC5_ME_MCTL_MODE(STANDBY_MODE) | SPC5_ME_MCTL_KEY_INV; for ( ; ; ) { uint32_t r = ME.IS.R; if ((r & 1U) == 1U) { break; } if ((r & 4U) == 4U) { break; } }I now get the following results:The target mode is STANDBY (0xD). ME.GS is indicating a transition is in progress. However, that's it. Nothing else happens. I waited 2 minutes, but it doesn't seem to go into standby mode. Do I have to disable all peripherals manually? I though that the CPU would handle that.Thanks,Mitchel2016-07-01 12:24 AM
And another update.
I get the controller into low power mode (can't check if it's standby, but the debugger says ''Target has entered STOP state'', so at least something. However, now comes the next problem: getting it out. I have a wake-up event setup:void setup_wakeup_trigger(void){ WKUP.WIPUER.R = 0xFFDFF; // enable all internal pull-up except the pad used (external pull-down) WKUP.WIREER.R = 0x200; // Rising edge enable WKUP.WISR.B.EIF = 0x200; // Status flag WKUP.WIFER.B.IFE = 0x200; // Filter WKUP.WRER.R = 0x200; // Enable wakeup}However, when I flip the switch on this pad (PB[10]), nothing happens. Anybody any ideas?2016-07-01 04:06 AM
And another update (made great progress today :))
I'm now at the point where I can get the controller in STANDBY and wake it up. However, when waking it up, the boot doesn't work correctly. It doesn't run through my code, it just skips between disabling and enabling global interrupts. I also tried boot from SRAM, but that doesn't change anything.As far as I understand, comming out of STANDBY should be equal to a reset right? Or it that assumption incorrect?2016-07-01 05:41 AM
2016-07-01 05:53 AM
Hi Erwan,
Thanks for the document. I'll take a look at is.As for RGM_STDBY: 0x0000.I also tried booting from backup ram = 1, but that didn't change anything. I got into the same loop as booting from flash.As for the state, my debugger isn't fast enough. Minimum refresh time is 500ms, and then I only see the change from STANDBY to RUN0, so can't check what's in between besides DRUNRegards,Mitchel2016-07-04 04:50 AM
Hi Erwan,
I still don't have the application working, but I did found something weird.I updated my standby transition code to the following: RGM.STDBY.B.BOOT_FROM_BKP_RAM = 0; WKUP.WISR.R = 0xFFFFFFFF; // Status flag ME.IS.R = 5; ME.MCTL.R = SPC5_ME_MCTL_MODE(STANDBY_MODE) | SPC5_ME_MCTL_KEY; ME.MCTL.R = SPC5_ME_MCTL_MODE(STANDBY_MODE) | SPC5_ME_MCTL_KEY_INV; for ( ; ; ) { }I don't really care what it does after going to STANDBY, so I just put it in an infinitive loop. After going to STANDBY, the debugger says ''Target has entered STOP state'' like before and when creating the wake up trigger, it says ''Target has left STOP state'' and doesn't continue properly. Nothing new so far.However, when I stop the debugger to see where in the code it is running, it's still in the infinitive for loop. It seems like my SPC560 isn't resetting. How is that possible?Thanks,Mitchel