6 Replies Latest reply on May 19, 2017 12:36 PM by JoMe_264151

    SCB UART interrupt

      I'm a psoc beginner and I'm trying to set an interrupt on FIFO is not empty.


      I'm recieving a RS-485 serial stream from an external board that sends data every 3 seconds or so. The signal is low between data update. I have confirmed that I am receiving the information correctly.


      The problem I'm faced with is the interrupt being continuously fired. I believe this is due to the RX FIFO accepting NULL between data being sent from the external board, which means the RX FIFO is always not empty.


      Is this proper behavior for the SCB UART? Is there a way to ignore incoming NULL characters? I expected it to be blocking until a non NULL character was received.


      I tried to search the forums but didn't find what I was looking for. First time posting, Any help would be hugely appreciated!



        • 1. Re: SCB UART interrupt

          This behavior comes from not removing the interrupt cause. You do not remove the character in the interrupt handler, so the FIFO stays not empty re-firing the interrupt over and over.





          • 2. Re: SCB UART interrupt

            Thank you so much! All I had to do was uncomment my function that was supposed to execute and handle the character during the interrupt and it worked. 




            I spoke too soon, it appeared to be working due to some other code. When you say I never clear the character from the FIFO buffer in the handler. Would UartGetChar clear the character clear it from the buffer? 


            I tried getting the characters, but it is still firing constantly. I also see some language about clearing the old interrupt in the datasheet for the UART SCB, but I'm not fully understanding it or whether or not it would apply to me.


            I'm still suspicious that the FIFO buffer is receiving an endless supply of NULL characters between the data sent because I've seen NULL characters appear on my display between the desired characters. 




            Thanks again for any help you can provide!

            • 3. Re: SCB UART interrupt

              You will definitively need to call SCB_ClearRxInterruptSource() API when the byte(s) have been red off from FIFO.


              It seems unusual that a device sends null data.


              Some suggestions:

              • An interrupt handler is usually a short piece of program. Ideally just setting a flag and exiting back into the shadows. In the infinite main loop the flag is tested, acted upon and reset again.
              • .h files are always #included in the corresponding .c files
              • Update your components to latest version.


              • 4. Re: SCB UART interrupt

                I have done the things you suggested. I stopped dealing with the interrupt and confirmed that the UART block is receiving null every time I UartGetChar() if there is not a "good" character being sent. I would appreciate any info you have as to why this might be happening it would definitely make my life a lot easier. I have scoured everything I could find and don't see an obvious solution or even whether or not this is working properly.




                Thanks for all your help so far.






                There is this line in the SCB datasheet that may explain why I would be printing null becuase UartGetChar() is returning 0 for no data.


                Return Value: uint32: Next data element from the receive buffer. ASCII character values from 1 to 255 are valid. A returned zero signifies an error condition or no data available. 


                This would mean that the FIFO would be empty and an interrupt wouldn't fire in those instances. I will continue with this knowledge and see if I get any good results.

                • 5. Re: SCB UART interrupt

                  Yep, all appears to be working! You're the man Bob!

                  • 6. Re: SCB UART interrupt

                    You are always welcome!