- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sir ,thanks for the given information.
Thanks & Regards
Vishnu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sir, can i interface my light sensor tsl235 directly with CY8CKIT-001 DVK .
Suggest me how i can interface my tsl235 with this kit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content