- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I made a simple app to play with interrupt handling. In loop it increments a counter and it's value is sent to UART.
When a byte is received on UART an ISR is called and the counter should be reset. By some reason the app works until a byte is received and than it hangs. The app hangs even if ISR has no code at all. Here is my code:
main.c:
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
#include <stdio.h>
#pragma interrupt_handler uartIsrRx;
unsigned char counter;
void main(void)
{
unsigned int i;
unsigned char str[16];
M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
UART_Start(UART_PARITY_NONE);
UART_IntCntl(UART_ENABLE_RX_INT);
while (1)
{
counter++;
csprintf(str, "c=%d\r\n", (int)counter);
UART_PutString(str);
for (i=0; i!=20000; i++);
}
}
void uartIsrRx(void )
{
counter=0;
}
UARTINT.asm:
_UART_RX_ISR:
...
...
;---------------------------------------------------
; Insert a lcall to a C function below this banner
; and un-comment the lines between these banners
;---------------------------------------------------
PRESERVE_CPU_CONTEXT
lcall _uartIsrRx
RESTORE_CPU_CONTEXT
reti
Attachment:
UART and PSoC global settings.
Best Regards
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is now done twice: remove the #pragma
or
change the code in UARTINT.asm to just a
LJMP _UARTIsrRx
In both of your original code-sections you issue a return from interrupt which pops one byte more from the stack than a simple return. So your stack gets clobbert and nothing runs anymore.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Bob! Now it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Congratulations!
Did you ever consider using a PSoC 4? There is the Pioneer Kit which is low-cost and has debugging capabilities (Breakpoints, variable inspection) which your PSoC1 Kit hasn't got. Additionally there is a 4$ Prototyping kit onto which you can load your debugged projects.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
http://www.cypress.com/?rid=77780 Pioneer Kit
http://www.cypress.com/?rID=92146 PSoC 4 CY8CKIT-049 4xxx Prototyping Kits
Regards, Dana.