- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Attached code demonstrates how to take the recived data inside UART ISR. Following steps needs to be performed on PD 5.3 for the same.
1. Create a custom UART user module. For that select Tools->User Module Customization Wizard. Select the User module and press Copy. Once the custom user module is created open the template of UARTINT.asm file from the folder where the module is stored.
2. Paste the following marker area just before the reti instruction that is present in the end of UARTINT.asm template file.
;@PSoC_UserCode_BODY_3@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom assembly code below this banner
;---------------------------------------------------
; NOTE: interrupt service routines must preserve
; the values of the A and X CPU registers.
;---------------------------------------------------
; Insert your custom assembly code above this banner
;---------------------------------------------------
;---------------------------------------------------
; Insert a lcall to a C function below this banner
; and un-comment the lines between these banners
;---------------------------------------------------
;PRESERVE_CPU_CONTEXT
;lcall _My_C_Function
;RESTORE_CPU_CONTEXT
;---------------------------------------------------
; Insert a lcall to a C function above this banner
; and un-comment the lines between these banners
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)
3. Place the custom user module,Build the project and open UARTINT.asm file.
4. Uncomment the lines
PRESERVE_CPU_CONTEXT
lcall _My_C_Function
RESTORE_CPU_CONTEXT
5. Define the function My_C_Function in the main.c and read the received data inside the function.
Please find attached project for your convenience. Thank you.
Regards,
Keerthy
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A method that can save some of the precious stack and CPU-usage is:
Declare your interrupt handler with the #pragma directive
Do not uncomment the PRESERVE and RESTORE-macros
Do not "LCALL" your handler, but insert a "LJMP _My_C_Function"
Within the handler My_C_Function() avoid calling any other functions.
This way your handler is an interrupt routine itself and the compiler will push only the needed data onto the stack which can increase performance.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Certainly using "ljmp" with #pragma directive has the advantages of stack-save and reduction in ISR execution time.
But one situation where we may have to use "lcall" is possibly this:
A few user module interrupt asm files of PSoC Designer have some code even after the user code marker area.
In such files, we may have to use "lcall"(along with preserve/restore of CPU registers) when calling routines defined in C.
This is because "ljmp" would result in jumping straight out of the interrupt after the C routine(due to the "reti" instruction placed the #pragma interrupt handler), and this would mean that the code following the "ljmp" in the user module asm file would not be executed, leading to unexpected operation of the user module.
Examples of files where there is code even after the user code marker area: ADCINCVR's interrupt asm file, UART's interrupt asm file when "Rx command buffer" is enabled etc.
Thanks & Regards,
Prem Sai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a method of altering the behaviour of an ISR. This is done by calling another function from within the User Module ISR. The function that is called from within an ISR need not be an interrupt handler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A bit late that last post, but...
When you call another routine from within your interrupt handler, the Image>Craft-Compiler is not able to evaluate which registers are used from within that routine. So at entry into the handler all registers will be pushed onto the (small) stack consuming MIPS and RAM.
Bob