- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When uart receives bytes, it does go entering to interrupt call back often.
I should send uart packet several times (2 ~ 8), then uart can receive.
Byte size is regardless.
Can anybody have same experiences?
int Uart_Init(BLE_PROFILE_PUART_CFG *puart_cfg, BLECM_FUNC_WITH_PARAM puart_rx_callback)
{
puart_selectUartPads(puart_cfg->rxpin, puart_cfg->txpin, 0x00, 0x00);
// Initialize the peripheral uart driver
puart_init();
// Since we are not configuring CTS and RTS here, turn off
// hardware flow control. If HW flow control is used, then
// puart_flowOff should not be invoked.
puart_flowOff();
//BEGIN - puart interrupt
// The following lines enable interrupt when one (or more) bytes
// are received over the peripheral uart interface. This is optional.
// In the absense of this, the app is expected to poll the peripheral
// uart to pull out received bytes.
// clear interrupt
P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);
// set watermark to 1 byte - will interrupt on every byte received.
P_UART_WATER_MARK_RX_LEVEL (1);
// enable UART interrupt in the Main Interrupt Controller and RX Almost Full in the UART
// Interrupt Controller
P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;
// Set callback function to app callback function.
puart_rxCb = application_puart_interrupt_callback;
// Enable the CPU level interrupt
puart_enableInterrupt();
/* END - puart interrupt */
}
void application_puart_interrupt_callback(void* unused)
{
// There can be at most 16 bytes in the HW FIFO.
char readbytes[16];
UINT8 number_of_bytes_read = 0;
while(puart_rxFifoNotEmpty() && puart_read(&readbytes[number_of_bytes_read]))
{
readBuffer[number_of_bytes_read] = readbytes[number_of_bytes_read];
number_of_bytes_read++;
ble_trace1("uart rx data is %d", (UINT8*)readBuffer[number_of_bytes_read]);
}
P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);
P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;
}
Solved! Go to Solution.
- Labels:
-
Peripherhal UART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I overwrite ws_upgrade_uart_init() and ws_upgrade_uart_interrupt_callback, then the problem disappeared.
I'm not sure the root cause still.
Diff has no issue before and after.
If I can get the root cause, I'll share
- 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
I should change the fist script.
it does does NOT go entering to interrupt call back often.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I overwrite ws_upgrade_uart_init() and ws_upgrade_uart_interrupt_callback, then the problem disappeared.
I'm not sure the root cause still.
Diff has no issue before and after.
If I can get the root cause, I'll share