6 Replies Latest reply on Mar 14, 2013 5:55 AM by DaKn_263916

    timer 16 isr

      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



        • 1. Re: timer 16 isr

          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:






             ;@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.)








          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.

          • 2. Re: timer 16 isr

            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



            • 3. Re: timer 16 isr

              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. 

              • 4. Re: timer 16 isr

                Sir ,thanks for the given information.




                Thanks & Regards



                • 5. Re: timer 16 isr

                   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.   
                  • 6. Re: timer 16 isr

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








                    Regards, Dana.