Topic : Interrupt vector.c file generation under ride 6

Forum : ST7/STM8

Original Post
Post Information Post
September 10, 2007 - 3:58pm
Guest

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).
Is it possible to do it in c ? surely but I don't know how.

best regards

Enrico

Replies
Post Information Post
+1
0
-1
September 10, 2007 - 4:55pm
Guest

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:

#define BITMASK_0 0x01
#define BITMASK_1 0x02
#define BITMASK_2 0x04
[...]
#define BITMASK_7 0x80

// or make a generic mask using a preprocessor macro:
#define BITMASK(i) ( (unsigned char)(0x01<<(i)) )

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

unsigned char mychar;
[...]
if ( mychar & BITMASK(3) )  // or: if ( mychar & BITMASK_3 ), depending on the solution you choose
{
   [...] // The code here is executed only if the bit 3 of mychar is set
}

// You can also check several flags at the same time:
if ( mychar & (BITMASK(3)|BITMASK(5)|BITMASK(6)) )
{
   [...] // The code here is executed if one of the 3 flags is set
}

Informations about about low level operators and bit fields in C can be found here.

regards,
Lionel

+1
0
-1
September 10, 2007 - 5:04pm
Guest

Thank you Lionel

Bye

Enrico

+1
0
-1
September 10, 2007 - 5:21pm
Guest

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

+1
0
-1
September 11, 2007 - 8:52am
Raisonance Support Team

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:

void irq4handler(void) interrupt 4
{
   // Place your interrupt handler code here
}

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

+1
0
-1
September 11, 2007 - 10:14am
Guest

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

+1
0
-1
September 11, 2007 - 1:55pm
Raisonance Support Team

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.