2015-06-30 06:48 PM
I am programming on pictus dspi module, I have queries describe below:
/********************************************/ DSPI(module).PUSHR.R = nCONT|DSPIx_CTAR0|nCS+ucDIN; while(DSPI(module).SR.B.RFDF == 0); //Point A DSPI(module).SR.B.RFDF = 1; //Point B /********************************************/ question are: 1) Read POPR should be inserted at Point A or Point B 2) From reference manual , I understand that RFDF is a flag indicating Rx FIFO is not empty, if I dont add any read DSPI_POPR code here, Will Rx FIFO be flushed to no entry level? Thanks! #dspi-pictusSolved! Go to Solution.
2015-07-02 07:03 AM
void
spi_serve_dspi_rfdf(SPIDriver *spip) {
osalSysLockFromISR();
/* Emptying the RX FIFO.*/
while
((spip->rx_cnt > 0) && (spip->dspi->SR.B.RXCTR > 0)) {
uint32_t frame = spip->dspi->POPR.R;
if
(spip->rx_ptr != NULL) {
if
(spip->dspi->CTAR[0].B.FMSZ < 8)
*spip->rx_ptr8++ = (uint8_t)frame;
else
*spip->rx_ptr16++ = (uint16_t)frame;
}
spip->rx_cnt--;
}
/* Interrupt served.*/
spip->dspi->SR.B.RFDF = 1;
''In the interrupt service routine, RFDF must be cleared only after the DSPIx_POPR register is read.''
2) RFDF is setwhile the RX FIFO is not empty. if you set 1 it will be reset.
Best regards
Erwan
2015-07-02 07:03 AM
void
spi_serve_dspi_rfdf(SPIDriver *spip) {
osalSysLockFromISR();
/* Emptying the RX FIFO.*/
while
((spip->rx_cnt > 0) && (spip->dspi->SR.B.RXCTR > 0)) {
uint32_t frame = spip->dspi->POPR.R;
if
(spip->rx_ptr != NULL) {
if
(spip->dspi->CTAR[0].B.FMSZ < 8)
*spip->rx_ptr8++ = (uint8_t)frame;
else
*spip->rx_ptr16++ = (uint16_t)frame;
}
spip->rx_cnt--;
}
/* Interrupt served.*/
spip->dspi->SR.B.RFDF = 1;
''In the interrupt service routine, RFDF must be cleared only after the DSPIx_POPR register is read.''
2) RFDF is setwhile the RX FIFO is not empty. if you set 1 it will be reset.
Best regards
Erwan
2015-07-02 06:53 PM
Hi, erwan.
I debug by UDE yesterday, It is true that I cannot write 1 to clear RFDF flag if I dont read POPR data first. It is better to check '' RX FIFO Counter'' as you suggest. Thank you so much!