cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

I have not used a lot of interrupts in my limited C experience with PSoC.  I am am basically wanting to set a pin high before I send data out my UART.  I am getting it done with the code attached, but only the first time through routine. I have tried clearing interrupt but i do not seem to see this option in the API, or don't understand it properly.

I will include a copy of my workspace'

#include "project.h"

CY_ISR( UART_done_Handeler)

{

Load_Write(0); // deactivate load pin when data completed

}

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

UART_done_Int_StartEx(UART_done_Handeler);

    UART_Start();

    for(;;)

    {

Load_Write(1); // activate load pin prior to sending data

    UART_UartPutString("O"); // send data over UART @ 2000 bps

Red_LED_Write(0); // turn RED LED on (active low)

CyDelay(500); // delay 500mS

Red_LED_Write(1); // turn off RED LED

CyDelay(500); // delay 500mS

    }

}

1 Solution
JoMe_264151
Expert II

There is a SCB_ClearTxInterruptSource() API which you need to call in your handler. Otherwise the same interrupt will fire over and over.

Bob

View solution in original post

0 Likes
Reply
4 Replies
Anonymous
Not applicable

My explanation of my code was not very clear in my original post.  In the code I want to set what i call Load pin hi at start of sending data and when the data has completed set the pin low.  The code does this perfectly as needed but only the first time though.  I believe my problem is i don't know how clear the interrupt when leaving the interrupt routine.  In the API i don't really see an option for clearing the interrupt. What am i missing in my understanding of this interrupt process.

0 Likes
Reply
JoMe_264151
Expert II

There is a SCB_ClearTxInterruptSource() API which you need to call in your handler. Otherwise the same interrupt will fire over and over.

Bob

View solution in original post

0 Likes
Reply
Anonymous
Not applicable

Bob thank you for helping me with this.  I am unclear as to what I put into the expression part of this API.

In my case it is UART_ClearTxInterruptSource(???)  What is expected in the expression?

I will try an d look at data sheet and see if i can educate my self.

Scott

0 Likes
Reply
Anonymous
Not applicable

Ok .... after reading AN90799 and Interrupt 1.7 I was able get better understanding of what was needed to fix my issue.  Since I am using a Fixed Function Interrupt Source  with an external interrupt, I need to deal with clearing the interrupt differently.  I also looked up an application of how a fixed function Timer CE195385 handled the same application as mine.  That being a fixed function source with an external Interrupt attached.

So a Bob directed me I need to use the following API call and MASK in my Interrupt handler routine to fix my issue.

CY_ISR(UART_done_Handeler)

{

Load_Write(0); // deactivate load pin when data

UART_ClearTxInterruptSource(UART_UART_INTR_TX_MASK);

Green_LED_Write(0);

CyDelay(50);

Green_LED_Write(1);

CyDelay(50);

}

Scott

0 Likes
Reply