Question
problem setting STM registers
Posted on January 25, 2016 at 17:14
Hallo everyone,
finally I have received a discovery board (with aSPC56EL60L3 mounted
) and installed the universal debugger, to try some of my code.I ran in the first problem trying to set a timer.I use this code: STM.CR.B.CPS = PRESCALER; /* Prescale value.*/ STM.CR.B.FRZ = 1; /* Allows Freeze for stop counter in debug. */ STM.CR.B.TEN = 1; /* Enable the counter. */I manage to debug and stop the application, but I am new in this field and problably there is some error that I do not see.The first thing that I note, is that the code is not executed in the order written. Looking the PC register with the debbuger, it seems that the instructions are ''scrambled'' in the compiling phase. The second instruction is executed beforre the first (I am debugging step by step).Is it possible?The second thing is that after the instruction STM.CR.B.CPS = PRESCALER; the program doesn't continue. I must press ctrl+F5 to stop it and then I see that the program is blocked on an unhandled exception.Someone can see the problem in the snippet of code. Reading the documentation, I understood that, after using the wizard generator, I can use the memory mapping autogenerated to modify register values. Is this correct? Or I understood wrongly how SPC5 studio works?Thank you, Ivan #stm-registers