Zurück zu Willert.de

interrupt stereotype

Rhapsody Model or Codegeneration topics

interrupt stereotype

Postby wvdheiden » July 27th, 2012, 2:12 pm

Customer Question:

Für die TI Werkzeugkette muss eine Interrupt-Routine mit dem entsprechenden Schlüsselwort versehen sein:
Code: Select all
  2. //---------------------------------------------------------------------
  3. interrupt void ADCINT1_ISR(void)                                        // PIE1.1 @ 0x000D40  ADCINT1
  4. {
  5.         static Uint16 *AdcBufPtr = AdcBuf;                              // Pointer to buffer
  6.         static volatile Uint16 GPIO34_count = 0;                            // Counter for pin toggle
  8.         PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;                                         // Must acknowledge the PIE group
  10.         //--- Manage the ADC registers
  11.         AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;                                           // Clear ADCINT1 flag
  13.         //--- Read the ADC result
  14.         *AdcBufPtr++ =  AdcResult.ADCRESULT0;                                       // Read the result
  16.         //--- Brute-force the circular buffer
  17.         if( AdcBufPtr == (AdcBuf + ADC_BUF_LEN) )
  18.         {
  19.                 AdcBufPtr = AdcBuf;                                         // Rewind the pointer to beginning
  20.         }
  22.         //--- Example: Toggle GPIO18 so we can read it with the ADC ***/
  23.         if(DEBUG_TOGGLE == 1)
  24.         {
  25.                 GpioDataRegs.GPATOGGLE.bit.GPIO18 = 1;                                  // Toggle the pin
  26.         }
  28.         //--- Example: Toggle GPIO34 at a 0.5 sec rate (connected to the LED on the ControlCARD).
  29.         //            (1/50000 sec/sample)*(1 samples/int)*(x interrupts/toggle) = (0.5 sec/toggle)
  30.         //            ==> x = 25000
  31.         if(GPIO34_count++ > 25000)                                      // Toggle slowly to see the LED blink
  32.         {
  33.                 GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;  // Toggle the pin
  34.                 GPIO34_count = 0;                                           // Reset the counter
  35.         }
  36. }

Kann man das aus Rhapsody z.B. über ein Sterotype für Methoden generieren lassen?
Who is General Failure and why is he reading my drive?
User avatar
Posts: 52
Joined: October 5th, 2007, 10:31 am
Location: Hellendoorn, the Netherlands
Company: Willert Software Tools GmbH

Re: interrupt stereotype

Postby shanz » July 27th, 2012, 6:29 pm

I don't speak Dutch or German but I think you are asking how to create a stereotype to flag a primitive operation as an ISR.
You could use the CPP_CG::Operation::SpecificationProlog to get the 'interrupt' keyword.
What else should it do?
Posts: 179
Joined: May 7th, 2008, 5:50 pm
Location: Horsham, W Sussex, England

Re: interrupt stereotype

Postby Skywalker » March 30th, 2013, 3:50 pm

@wvdheiden) Yes, you can!

@shanz) is right in principle, recommending the mentioned property CPP_CG::Operation::SpecificationProlog for a generated .h file (and CPP_CG::Operation::ImplementationProlog for generated .cpp file) to do that.

But it may be better to use the more specialized property named CPP_CG::Operation::PreDeclarationModifier for that purpose and leave the other properties open for purposes like conditional compilation switches.

In any case, you may want to define a Stereotype named like "IrqFunc" (probably do this in a separate profile, in order to make it reusable across projects) and set that property value on level of the new Stereotype.
The stereotype must be set to be applicable to "Operation" (this means regular operations vs. Rhapsody's Triggered Operations and Event Receptions) and eventually you define it as a "New Term" (another selection on general tab of Stereotype feature dialog) to create a new category in the model browser, where operations with that stereotype get categorized more visibly.

Additionally you could apply even more properties via that stereotype (e.g. CG::Operation::Animate to False), if they make sense in the context of an interrupt handler.

May the force be with you ...
Posts: 74
Joined: October 31st, 2007, 5:09 pm
Location: Milkyway, classic 9-planet solar system

Re: interrupt stereotype

Postby ftheile » September 4th, 2014, 5:33 pm


I have a similar problem.
I want to generate an operation that looks like this:
Code: Select all
void __ISR(_TIMER_5_VECTOR, ipl7) C_Motor_Timer45_Interrupt(void)
  // ...

I have a stereotype "Interrupt", which overloads property C_CG::DeclarationModifier with __ISR().
But how can I pass the two arguments (_TIMER_5_VECTOR and ipl7 in the example) to the __ISR() macro?

I tried to add a tag v with a multiplicity of 2 to the stereotype, but I don't know how to output the passed arguments into the generated code.
Posts: 1
Joined: March 5th, 2014, 10:04 am

Re: interrupt stereotype

Postby wvdheiden » November 24th, 2014, 1:50 pm

Hi Frank

This is not possible with the regular Rhapsody Code generation. You could use custom code generation to insert Tag Values into your code.
Why not create multiple stereotypes? <<INT_V5_I7>> and so on?

Who is General Failure and why is he reading my drive?
User avatar
Posts: 52
Joined: October 5th, 2007, 10:31 am
Location: Hellendoorn, the Netherlands
Company: Willert Software Tools GmbH

Return to Modelling with Rhapsody

Who is online

Users browsing this forum: No registered users and 2 guests