In one of my project while programing Psoc4 device , I am facing issue with the UART Rx interrupt.
In UART component I have set the size of the UART Rx and Tx buffer to 64. hence i will have to access only the internal Rx interupt (I have selected the Rx FIFO level =7 in the check box selection).
A sample code snippet which wasnt even working is mentioned below . Please let me know where am i wrong
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
SER_Init(); // Intialize Seial port// Start the SCB UART
SER_Start(); // Enabling the UART //
if ((SER_GetRxInterruptSourceMasked() & SER_INTR_RX_FIFO_LEVEL) != 0)
Also I would like to have an code example of one wire component
The "internal" interrupt is used to maintain a circular buffer and reads all data off the receiver FiFo. Your interrupt changes status information and reads data, so it will infer with the internal interrupt handler. Have a look at the description of SER_SetCustomInterruptHandler. I would suggest you to either
Just set a flag in your handler which you check in your main-loop
use SER_UARTGetRxBufferSize() to poll for characters received.
Enter "1-wire" (with the quotes) into the keyword search field at top of this page
Also enter "One Wire" with the quotes.
A component -
Hey Bob ,
Thanks for your reply......
My application is that I am actually going to receive a string of 40 char.. from which i have select my desired characters and process them. I have worked with external UART ISR which works completely fine when my data was about 8 char. but since I have to handle more than 8char and the limitation of hardware Rx and Tx fifo ,I have to use the internal Rx interrupt by setting the buffer size to 64.
As per documentation when working with the internal interrupt, we have pass the address of user defined interrupt handler to the SetCustomInterruptHandler() function. If you refer the code snippet above during intialization in main() function I have passed the address of my Inthandler to the function.
So now whenever I receive any byte on UART ,the UartIntHandler() will be called first, so I have just placed the Ser_UartPutChar() only to let me known whether this function is called or not as I playing with bootable application
Now , This is what is not been performed. when i send any byte to the cypress I am not observing 's' been transfered from cypress i.e the control is not passed to my UartInthandler().
I would like to known , when working with the internal Rx interrupt what I have do which interrupt source I have to check and clear after performing my operation .
Do not clear anything, do not read any status, do not read a byte from UART , I (personally) would not even write to the UART, at least not within an interrupt handler. Do you use a CY8CKIT-049-42xx ? Good idea would be to post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
check this example of UART Rx an dmodify it for your needs:
There is an example of receiving UART strings and simple commands to control RGB LED on PSOC4 Pioneer Board: UART4_RGB_01-000.cywrk.Archive01.zip
Thanks for your support...
Yes I am using CY8CKIT-049-42xx and the uart used is SCB UArt .
I have a string of 40 chars that will be received by the cypress Uart, So I have set the Uart Rx FIFO to 64 in the Uart component, due to this my internal Rx interrupt is to be handled. I have set the Rx_FIFO_LEVEL to 1 so that I have an interrupt with ever byte received. Using the SetCustomInterruptHandler() my internal Rx interrupt is fired.
Which interrupt i have to clear in my interrupt handler, what is the .
One more question.
Suppose I get data string in Rx FIFO and using GetChar() function I read one data byte from Rx fifo . But the read byte is still in the Rx fifo how can I clear that read byte in rx fifo so that it wont be read again
The byte is cleared automatically and you will not read it again. When reading more bytes than are in the buffer an error overrun flag will be set in the status.
There is an API SER_GetRxInterruptSource() which result you may feed into SER_ClearRxInterruptSource() to reset all pending interrupts of the receiver.
Rx_FIFO_LEVEL is not a right flag to read the received UART values.
If you are sure that you are sending 40 bytes of data, then use the SCB_SpiUartGetRxBufferSize() to see how many bytes are received. Or you can start reading the data until the buffer is not zero.
while(SCB_SpiUartGetRxBufferSize() ! =0)