- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What can it be when the function (while(0u == (nRF_SPI_GetMasterInterruptSource() & nRF_SPI_INTR_MASTER_SPI_DONE))) goes to infinite loops?
void SPI_wait_done() {
nRF_SPI_ClearMasterInterruptSource(nRF_SPI_INTR_MASTER_SPI_DONE);
while(0u == (nRF_SPI_GetMasterInterruptSource() & nRF_SPI_INTR_MASTER_SPI_DONE))
; /* Wait while Master completes transfer */
/* Clear interrupt source after transfer completion */
nRF_SPI_ClearMasterInterruptSource(nRF_SPI_INTR_MASTER_SPI_DONE);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The API nRF_SPI_GetMasterInterruptSource() will returns Master interrupt request register. This register contains current status of Master interrupt sources. The master interrupt source nRF_SPI_INTR_MASTER_SPI_DONE will describe that SPI master transfer is completed.
The function (while(0u == (nRF_SPI_GetMasterInterruptSource() & nRF_SPI_INTR_MASTER_SPI_DONE))) goes to infinite loops when the SPI master transfer is not completed.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I would do something like
=============================
int SPI_wait_done() {
int result = OK ;
uint32_t timeout = 0xFFFFFF ; /* some big number to wait */
nRF_SPI_ClearMasterInterruptSource(nRF_SPI_INTR_MASTER_SPI_DONE);
while(0u == (nRF_SPI_GetMasterInterruptSource() & nRF_SPI_INTR_MASTER_SPI_DONE)) {
if (--timeout == 0) {
result = TIMEOUT ;
break ;
}
}
...
=============================
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The API nRF_SPI_GetMasterInterruptSource() will returns Master interrupt request register. This register contains current status of Master interrupt sources. The master interrupt source nRF_SPI_INTR_MASTER_SPI_DONE will describe that SPI master transfer is completed.
The function (while(0u == (nRF_SPI_GetMasterInterruptSource() & nRF_SPI_INTR_MASTER_SPI_DONE))) goes to infinite loops when the SPI master transfer is not completed.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please refer the PSoC4 Serial communication Block(SCB) Component for more information in the below link.
http://www.cypress.com/file/220331/download
Thanks,
P Yugandhar.