cancel
Showing results for 
Search instead for 
Did you mean: 

uint32_t problem with STVD + Cosmic FSE

Radim Bajak
Associate
Posted on August 14, 2017 at 18:04

Hello, I use STM8AF52xx, STVD and cosmic FSE, when I try to use  STM8S_StdPeriph_Lib and CAN example I encounter this error:

&sharperror clnk Debug\stm8af52ax.lkf:1 @svlreg missing for function f_CAN_RX_IRQHandler

(I have deleted LCD and LED functions just to have pure CAN because there was similar error concerning LCD/LED).

This is part of code that is responsible for error:

it is can_recieve() routine

0690X000006041CQAQ.jpg

As it seems error is caused by uint32_t variables, more precisely with data manipulations.

I was able to assign pure numerical value, but combined statement (assign value from other variable and for example shifting left ) throws error.

I can compile stm8s_can.c without problem, but if try to I build whole project I got error as stated at beginning.

If I comment code with uint32_t variables project would build without errors.

Workspace is available in attachment. 

What is causing this error?

best regards,

Radim.

##error-clnk-@svlreg-missing-for-function*
1 ACCEPTED SOLUTION

Accepted Solutions
luca239955_stm1_st
Senior II
Posted on August 16, 2017 at 15:55

Hello,

as the linker says add @svlreg to your function declaration (both prototype and actual function) and the problem will go away.

The issue is that when using 32 bits variables in interrupt functions the compiler must save the internal variable c_lreg (used for this kind of calculations) on the stack under interrupt to avoid possible corruption; this is controlled by the @svlreg keyword.

Regards,

Luca

View solution in original post

7 REPLIES 7
luca239955_stm1_st
Senior II
Posted on August 16, 2017 at 15:55

Hello,

as the linker says add @svlreg to your function declaration (both prototype and actual function) and the problem will go away.

The issue is that when using 32 bits variables in interrupt functions the compiler must save the internal variable c_lreg (used for this kind of calculations) on the stack under interrupt to avoid possible corruption; this is controlled by the @svlreg keyword.

Regards,

Luca

Posted on August 16, 2017 at 22:52

thank you very much for your time and effort, I was not aware of this 

best regards,

R.

Posted on September 13, 2017 at 02:07

Hi Luca

How do i add this to my project?, (sorry for the newbie question) i'm new using this IDE.

Hello,

as the linker says add @svlreg to your function declaration (both prototype and actual function) and the problem will go away.

Thank you very much

Best regards

Posted on September 14, 2017 at 08:51

Hello,

it's in the source code, it does not depend on the IDE.. at some point you have an interrupt function like

@interrupt void my_interrupt_function(void) { ..interrupt function using 32 bits math.. }

and you just add @svlreg to it so that it becomes

@svlreg @interrupt void my_interrupt_function(void) { ..interrupt function using 32 bits math.. }

Regards,

Luca

Posted on September 19, 2017 at 20:34

Hello, what documentation would you recommend to understand such syntax? i haven't seen it before.

Any info will be apreciated 

Best regards
BCowa
Associate II

I am having this problem also but when I add @svlreg to the interrupt function prototype and function I now get the following linker error:

clnk -l"C:\Program Files (x86)\COSMIC\FSE_Compilers\Lib" -o Debug\5971.sm8 -mDebug\5971.map Debug\5971.lkf

#error clnk Debug\5971.lkf:1 segment .bsct size overflow (277)

#error clnk Debug\5971.lkf:1 segment .ubsct size overflow (3218)

#error clnk Debug\5971.lkf:1 segment .bit size overflow (9)

 The command: "clnk -l"C:\Program Files (x86)\COSMIC\FSE_Compilers\Lib" -o Debug\5971.sm8 -mDebug\5971.map Debug\5971.lkf " has failed, the returned value is: 1

exit code=1.

I am new to STM8 and Cosmic. Any suggestions please?

Cheers, Bruce

luca239955_stm1_st
Senior II

Hello,

I don't see how just adding @svlreg can make your segments overflow.. please make sure you start from a project that does compile and link correctly, then add @svlreg only (no other modifications), compile again and check the result.

If you can't make it work you can contact our support at support@cosmic.fr

Regards,

Luca (Cosmic)