- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have searched around but have not found an answer on how to do this.
I read the SCB documenation but the interrupt information doesn't make much sense to me.
What I want is to have an interrupt fire on every byte received.
I have attached an external interrupt (I think this is the right one, it says for 8 bytes or less use an external)
In advanced I have selected RX FIFO not empty and RX FIFO full. The UART is working but it just does not seem to fire the interrupt.
I have attached my code if someone can spot the error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another problem I have is that I cannot place a hardware breakpoint on the interrupt file.
I am using the USB debugger on the PSoC 4 Pioneer but I have also tried my miniprog3. Both just won't place a hardware breakpoint on the ISR. It offers to replace them with software ones but they don't break..
This is with no other breakpoints on the project
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do nto see where you issued a -
UART_RX_FULL_Start( );
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dana
Thanks for the reply
You are right I missed that off, but I have since added it and now I can put breakpoints on the ISR.
However the ISR is still not firing or changing the flag. 😞
- 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
You misunderstood how the interrupts work. Fot the UA<Rt the interrupt is a pure signal to which you connect an interrupt handler as you did. This module has to be initializes preferrably with isr_StartEX(YourHandler).
Declare and define the handler with
CY_ISR_PROTO(YourHandler);
and
CY_ISR(YourHandler)
{
// Check UART Status
// Remove cause of interrupt (Reading received Bytes until FIFO empty
}
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should declare the flag as volatile -
http://www.barrgroup.com/Embedded-Systems/How-To/C-Volatile-Keyword
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob, why can't he use the place holder ISR function tool generates ? Where
he set the flag......
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure how to do what Bob has suggested
But I have now added the volatile keyword on both the main.c and on the interrupt "extern uint8 volatile flag"
I've attched the updated code again but it is only this keyword which has changed.
The code inside the "if(flag == 1)" loop never gets called.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The new bundle you posted just has timer based projects in it,
not UART we were working on ?
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Dana
He CAN use it when using it correctly. He had an ist component dropped onto the schematic which he did not use and an interrupt handler within the component he did not use neither because the interrupt was not explicitely enabled.
So I pointed out the usual working approach that always leads to success by using the isr_StartEx() and CY_INT().
@Sam
Lookup "CY_ISR" keyword in the "System Reference Guide" (from Help-Menu) and check the APIs in the isr-datasheet.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On the schematic he dropped ISR component named UART_RX_FULL, and in the
UART_RX_FULL.c file generated by tool is a placeholder where he added the flag = 1; statement -
CY_ISR(UART_RX_FULL_Interrupt)
{
/* Place your Interrupt code here. */
/* `#START UART_RX_FULL_Interrupt` */
flag = 1;
/* `#END` */
}
And then enabled it in main (globals enabled as well).
So what is wrong with this ? What am I missing ?
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
He had enabled it in main() after I indicated he should do so.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did not have the latest workspace bundle. So latest update's interrupt should work
if
in the interrupt routine the cause of interrupt is not removed, ie the character is not red off.
in main() any characters are continously red, so interrupts may not happen.
I would suggest to
read the UART Rx-status within the interrupt routine to clear sticky status-bits
read the character within the interrupt routine to a global char when status indicated fifo not full
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys
Sorry about the delay, Thanks for all the help by the way
I have tried to read the status as you suggested but I am not sure I am using the right command, anyway the code still never gets into the flag bit so the flag isn't being set.
I have attached the up to date workspace bundle, I don't know what happened with the last one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This seems to indicate no need for clearing interrupts as you are in external mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Doesn't one have to uncomment the #START and #END in the ISR placeholder ?
*******************************************************************************/
CY_ISR(UART_RX_FULL_Interrupt)
{
/* Place your Interrupt code here. */
/* `#START UART_RX_FULL_Interrupt` */
flag = 1;
UART_rx_Read(); // Clear interrupt?
/* `#END` */
}
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I try to uncomment them I get a syntax error..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Don't uncomment the lines, my mistake.
I see the following note in this ap note (AN54460) -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I looped back Tx to Rx pin, set isr to level triggered, and I am hitting
breakpoint in interrupt routine. Not looped back I am still hitting
BP. I assume thats becuse FIFO not emptied.
Setting ISR back to derived not interrupt..
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dana
You are right the interrupt is firing when I do a loop back test and use level triggered interrupts.
New problem though, it never gets out of the interrupt! the read doesn't clear the interrupt it seems.
Thankyou so much for experimenting with me, I so wanna use Cypress stuff but I keep finding niggles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But doesn't this code -
for(;;)
{
TX_LED_Write(1);
ch = UART_UartGetChar();
if(flag == 1)
{
flag = 0;
UART_UartPutChar(ch);
TX_LED_Write(0);
}
}
When first char received, flag gets set, you then read out of fifo (emptying it), and then
you put char right back into fifo causing another interrupt ?
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sam,
I am experience the same problem as you - I am comfirming with my logic analyzer that data is coming in on the RX line, I have also confirmed that if I write something to the TX line using UART_UartPutChar(tx_data), data is transmited. My uart_isr interrupt never gets activated. Have you found a solution to yours yet?
All the Best,
Katrine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all
FIXED IT!
Well someone from Cypress helped me fix it.. The problem I was having was as Dana suggested I was trying to put a character out before I checked for the flag, I also was not properly clearing the source of the interrupt..
The cypress applications engineer showed me how to properly check for the source of the interrupt and to clear it, since doing this it is working perfectly.
I have attached the bundle.
Just want to say a big thankyou to everyone in the thread for their help 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For those who don't want to download the project here is my main loop
and here is my interrupt code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great work!
Thank you for sharing
- 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
@TAKASHI
When using IE, switch on the "Compatibility Mode"
Bob
- 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
You need to call SCB_ClearRxInterruptSource (or SCB_ClearTx...) to clear the interrupt flag. (See the SCB datasheet page 116).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Look at my last post and play with the "Compatibility mode"
Bob