timer 16 isr

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

cross mob
Anonymous
Not applicable

i,ve studied the datasheet of timer 16. They mentioned that we have to write isr in assembly only, but i dont know how to call this interrupt routine from main program.

   

Thanks & Regards

   

Vishnu

0 Likes
6 Replies
Anonymous
Not applicable

If you want to write the ISR in assembly, then you can open the ISR file generated by PSoC Designer and add code inside the user code marker area.  For example, if you Timer16's instance name is TIMER16_1, then you will find the ISR file TIMER16_1int.asm in the "\lib\Library Source Files" in the workspace explorer.  You will find code like this in this file:

   

 

   

_TIMER16_1_ISR:

   

   ;@PSoC_UserCode_BODY@ (Do not change this line.)

   

   ;---------------------------------------------------

   

   ; Insert your custom code below this banner

   

   ;---------------------------------------------------

   

   ;   NOTE: interrupt service routines must preserve

   

   ;   the values of the A and X CPU registers.

   

 

   

   ;---------------------------------------------------

   

   ; Insert your custom code above this banner

   

   ;---------------------------------------------------

   

   ;@PSoC_UserCode_END@ (Do not change this line.)

   

 

   

   reti 

   

 

   

You should write your ISR code within the two markers.  If you want to write an ISR in C, then you will have to write a C function declared as an ISR using #pragma Interrupt_handler and then place an ljmp instruction to this C function in the above ISR file.

0 Likes
Anonymous
Not applicable

Thanks for the reply. 

   

                    I would like to know that , for writing an ISR  which language is better(C or ASM)? and why ?

   

 

   

Thanks and Regards

   

Vishnu

0 Likes
Anonymous
Not applicable

Actually both the methods have their merits.

   

 

   

Ideally, assembly is preferred for writing an ISR.  When you write a C ISR, and if there is another function call from within the C ISR, the compiler saves all the virtual registers and page pointers to the stack before entering the function and restores them before exiting.  As the compiler does not know which registers the called function is going to modify, it has to save and restore all the virtual register.  This takes a lot of time.  But when you write an assembly ISR, you know the registers that are going to be modified and you will save and restore only the necessary ones.  This way, the ISR will execute faster.

   

 

   

On the other hand, C ISR is easier to write and maybe preferred by many.

   

 

   

You could strike a balance by using both.  For ISRs that are not very time critical, you can use C ISR.  Also, while using C ISR, avoid calling functions from within the ISR.  For ISRs that are time critical, use assembly. 

0 Likes
Anonymous
Not applicable

Sir ,thanks for the given information.

   

 

   

Thanks & Regards

   

Vishnu

0 Likes
Anonymous
Not applicable

 sir, can i interface my light sensor tsl235 directly with CY8CKIT-001 DVK .

   

Suggest me how i can interface my tsl235 with this kit.

   
     Actually my work is to detect light intensity of different laser and measure its frequency and develop a device which is very sensitive. so i m using TSL235 converter for my work.   
   
     i need to do it on PSoC designer. help send me designing sample and if possible code also.   
   
     Thanks   
0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Here is a application note to measure frequency on PSOC 1 -

   

 

   

www.cypress.com/

   

 

   

Regards, Dana.

0 Likes