Software interrupt

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello everyone,

   

i would like to execute a part of my code just once and i was thinking about using software interrupt.

   

can someone tell me how to configre it?

   

Thanks for any help

   

Regards

   

Claire

0 Likes
10 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A software interrupt is raised by a software instruction. This usually comes in handy to expose an interface of an RTOS to some  processes. For a normal project it would be easier to just "Call" the appropiate function which additionally has the advantage that parameters can be specified and a return-value can be given back.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Claire, tell me what you are trying to accomplish -

   

 

   

1) What will you use to trigger the ISR

   

2) What the ISR has to do

   

3) Is it a one time only ISR or a periodic one ?

   

4) Why is it software only ?

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Hello Dana,

   

1) What will you use to trigger the ISR

   

2) What the ISR has to do

   

3) Is it a one time only ISR or a periodic one ?

   

4) Why is it software only ?

   

i am reading an ADC value, with whom i produce a PWM. I would like to produce after first read of ADC value, a PWM with double frequency, whose frequency i want to decrease until it is no longer double, and then continue the program without double the frequency anymore.

   

I would like to use the first read of ADC value as a trigger, the decrease of PWM frequency as the ISR (which will be perform only once)

   

I thought it has to be software only because it is after reading the ADC value that i want to use the ISR to decrease the double frequency.

   

 

   

Thanks for replying

   

Regards

   

Rosine

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Wouldn't it be easier to use in your PWM setting function a construct like

   

void SetPWM(uint16 ADCValue)

   

{

   

uint16 PWMCompare;

   

static uint8 FirstRead = FALSE;

   

    PWMCompare = ADCValue; // or any function value depending on ADCValue

   

    if(FirstRead)

   

    {

   

        PWMCompare /= 2;

   

        PWMRead = TRUE;

   

    }

   

    PWM_WriteCompare(PWMCompare);

   

}

   

 

   

under the assumption that you want to modify the pulse-width and not the frequency

   

 

   

Happy coding

   

Bob

0 Likes
Anonymous
Not applicable

Hello Bob,

   

thanks for replying. I got this idea too, but the problem is, that by doing so, the execution of the program become very slow.

   

Regards

   

Rosine

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

An interrupt will consume quite more time, since the actual processor status has to be saved on stack and later retrieved. On the other hand will your PWM consume some time for one period which usually is quite long compared to the execution time needed to check and branch on a local variable. Can you post your complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.



Bob
 

   

PS: Must leave, will be back 19:00h Local Time Bremen

0 Likes
Anonymous
Not applicable

Hello Bob,

   

the problem is solved. Thanks any way.

   

Regards

   

Rosine

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Just for curiosity: How did you solve your problem and what did you change?

   

 

   

Bob

   

PS: Where are you located in Germany??

0 Likes
Anonymous
Not applicable

i just wanted to know how to create a software interrupt.

   

by applying a control register to an interrupt(UDB) and using the interrupt pending function in the main function, the software interrupt is created.

   

i am arround  Hamburg.

   

Regards

   

Rosine

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Easiest is to use an interrupt component and after initialization use the Isr_SetPending() API.

   

 

   

Bob

   

PS Are you planning to visit Cypress at "embedded world" in Nürnberg next week? It has always been very informative to talk to the Cypress staff there.

0 Likes