Forum : ST7/STM8
Original Post
Post Information | Post |
---|---|
September 10, 2007 - 3:58pm
|
Dear raisonance team and forum stuff, 1) How can I generate the interrupt vector map with rbuilder ? because I can't see the file in my project directory. 2) I'm migrating from asm to c. I used in asm an 8 bit variable as flag (every bit assigned to a flag name). best regards Enrico |
Hi Enrico,
1) If I remember well, you are using RCST7 (Raisonance Compiler).
Using this toolchain, no interrupt vector map is generated on file, it is automatically generated by the linker (RLST7) depending on "interrupt" directives in the code.
2) Here is an example of how to do this: you can define a mask for the bits you are interested in, for example:
then apply the mask on a char variable using the bitwise AND operator (&) and check that the result is non null. The code to do that is
Informations about about low level operators and bit fields in C can be found here.
regards,
Lionel
Thank you Lionel
Bye
Enrico
Dear Lionel,
Thanks for your interest.
Another question.
I want to generate the vector file.
I have done the following file vector.c from a sample
extern void _stext();
void (* const _vectab[])() = {
_stext, /* NOT USED */
_stext, /* SPI */
_stext, /* LT_TB */
_stext, /* LT_IC */
_stext, /* LART OVF */
_stext, /* LART OCMP */
_stext, /* AVD */
_stext, /* NOT USED */
_stext, /* NOT USED */
_stext, /* EI3 */
_stext, /* EI2 */
_stext, /* EI1 */
_stext, /* EI0 */
_stext, /* NOT USED */
_stext, /* TRAP */
_stext /* RESET */
};
As you can see I tried to do an external _stext routine to manage a dummy interrupt as following:
void _stext (void) interrupt 1
{
_nop_() ;
}
Can you tell me if this is the right routine to manage a dummy interrupt ? ( I tried to generate one with _rim_ instruction)
best regards,
Enrico
Hello Enrico,
It looks like the example you selected is for the Cosmic compiler.
One of the benefits of using RCST7 is that it *automatically* handles interrupts. You do not have to worry about the interrupt vectors, which will be set automatically by the compiler and silently relocated to the proper address by our linker.
What you have to do is declare your interrupt handler (let's say for interrupt 4) as follows:
The compiler will automatically save registers (if required) and place the IRET at the end of the handler.
Our library is fully reentrant, so you can call whatever function you want from your handler (even printf).
I hope this helps,
Bruno
Really thanks Bruno and Lionel.
I have a question not related to this topic.
I'm converting an st7 board from assembler to c.
My head office told me if it's possible to mantain an old assembler part of the (about 50%) for security reasons.
I have already read the rcst7 manual for interactions between c and assembler.I think that I can use from c my old assembler routine,but not more.
My head office believe that assembler is more safe than c.I don't know if it's true.Our application are flame control and modulation.
The "50% of assembler code" I refer is managed only by watchdog timer to generate a time base to control all the software flux and it's about 4kbytes.There are various input port check,output command,a trace and different reduntand variables to check if the flux fail.
I think that is possible to translate to c,but I don't think that Is possible to mantain this assembler part and build the rimanent code in c.
What do you think about this ?
Best regards,
Henry
Hy Henry,
Technically: Your project is certainly portable to C. If you ensure that your program compiles without any warning and check it through C-Lint (or another code verifier), the generated code should be as safe as assembly.
Strategically: Your boss may prefer keeping an old -proven- code, even if it is in assembler and harder to maintain.
The baseline, in my opinion, is that you should keep your old assembly code as long as it works unmodified. If it needs any modifications, port it to C and enjoy life.
Regards, Bruno.