- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Uart Rx interrupt ISR stopped after receive data at the first time. Attach code, please check and tell me what's the problem.
thanks a lot!
Solved! Go to Solution.
- Tags:
- psoc 4000s
- uart
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I would re-write GetRecv() like below
============================
uint32_t GetRecv()
{
uint8_t ch; /* changed to uint8_t */
uint32_t size = 0;
uint32_t real_size = 0;
uint8_t tmpBuffer[256];
while(UART_SpiUartGetRxBufferSize()) {
tmpBuffer[real_size++] = UART_UartGetChar() ;
if (real_size >= sizeof(tmpBuffer)) {
break ;
}
}
if (real_size > 0) {
size = WriteRingBuffer(tmpBuffer, real_size, &s_RingBuffer);
}
return size ;
}
============================
If it does not work, I'm sorry (in advance).
moto
- 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
Hi,
I would re-write GetRecv() like below
============================
uint32_t GetRecv()
{
uint8_t ch; /* changed to uint8_t */
uint32_t size = 0;
uint32_t real_size = 0;
uint8_t tmpBuffer[256];
while(UART_SpiUartGetRxBufferSize()) {
tmpBuffer[real_size++] = UART_UartGetChar() ;
if (real_size >= sizeof(tmpBuffer)) {
break ;
}
}
if (real_size > 0) {
size = WriteRingBuffer(tmpBuffer, real_size, &s_RingBuffer);
}
return size ;
}
============================
If it does not work, I'm sorry (in advance).
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your guidance. I tried it and the result looks good. Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I check the code you post, there is little difference that add a condition before call UART_UartGetChar() , Is it because the function is called too often that the interrupt is unresponsive?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
UART_UartGetChar() returns 0 when no more char is available or an error arose.
But I feel accessing an empty buffer or when an error arose is not a good idea,
so I check the number of data available before accessing the buffer.
moto