2016-01-25 08:14 AM
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-registers2016-01-25 09:06 AM
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. */
Did you try to set directly the register with masks ?
it is recommended not to use the bitfield.
STM.CR.R = PRESCALER_MASK | FREEZE_ENABLE | TEN_ENABLE;
// example
Best Regards
Erwan
2016-01-26 12:26 AM
Hello Erwan,
I tried your solution and it worked. Thank you very much. As a side note, I tried to set a pin at 1SIUL.GPDOB.PDO = 1;
and this instruction is executed, but now I fear that, even if I have no exception, I am setting the wrong memory address.
In case this is not correct (as it seems from your aswer and from the debugger), when does the bitfield is used? Can I use it to read registers without using masks?
Regards,
Ivan
2016-01-26 01:02 AM
SIUL.GPDOB.PDO = 1;
Setting 3 successive bitfields at the same address is not recommended. Some compilers can optimize assembler routine and generate an unhandled exception
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. */
2) for reading , you can use whatever you want.
3) Anyway , you can check in the SFR View
Best Regards
Erwan
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. */
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. */
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. */
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. */
SIUL.GPDOB.PDO = 1;
and this instruction is executed, but now I fear that, even if I have no exception, I am setting the wrong memory address.
2016-01-26 01:25 AM
Ok, now I understand.
Thank you very much for the info, Ivan2016-01-27 12:17 AM
Good morning,
sorry for the double post, but I don't know if the problem of today is related with this discussion. I tried vairous registers to grasp the essentials of the SPC56EL60L3 mounted on my discovery board. I inserted this trial configuration:CRC.CFG1.R = 0;
in order to access and configure (for now with all bit fields to 0), the CRC module.
The micro give me an axception.
The strange thing that I note is that, using SFR view, I cannot monitor the CRC register. In the columns of values I see ?????????? instead of a value.
Reading the manual I found that CRC bit field are modifyable only in configuration mode.
Could be this the problem? In that case, how can I enter configuration mode? I searched the manual, but I didn't found the specific section (probably I misunderstood it).
Thank you,
Ivan
2016-02-23 07:57 AM
Hello Ivan ,
Sorry for my late answer Sometimes it is difficult to browse on Non-solved posts on my.st.com. You need to enable the associated PCTL. For CRC, you need to enable PCTL/* CRC clock gating if present.*/
halSPCSetPeripheralClockMode(58,
SPC5_ME_PCTL_RUN(2) | SPC5_ME_PCTL_LP(2));
you should see the value and not ???? (undefined).
Best regards
Erwan
2016-02-29 06:48 AM
Thanks for the answer Erwan.
I managed to activate the CRC module and now I better understand the external peripherals.Regards, Ivan