Hi,
Im reffering the MPC5676R example for developing similar SPI interface with flash with that of MPC5777c .I have a clarification regarding some commands requiring chip select low and execute and make it high after it.
Where in this example is t executed ? is it in the PUSH and Push ENQ where the CONT bit is set and EOQ bit is set.
the code snippet where its required is given below,
and if that is the case ALLOW Transfer is used for what. could u pl explain.
The below example is reffered.
https://community.nxp.com/docs/DOC-335461
#define ALLOW_TRANSFER DSPI_B.SR.R = DSPI_SR_EOQF
#define WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY while (!(DSPI_B.SR.B.RFDF)) {}
#define WAIT_UNTIL_TxFIFO_IS_FULL DSPI_B.SR.R = DSPI_SR_TFFF; \
while (!(DSPI_B.SR.B.TFFF)) {}
#define continuous_command_for_PUSH(x) DSPI_PUSHR_PCS1 | \
DSPI_PUSHR_CTAS(1) | \
DSPI_PUSHR_CONT | \
DSPI_PUSHR_TXDATA(x)
#define end_command_for_PUSH(x) DSPI_PUSHR_PCS1 | \
DSPI_PUSHR_CTAS(1) | \
(uint32_t) DSPI_PUSHR_EOQ | \
DSPI_PUSHR_TXDATA(x)
#define PUSH(n) DSPI_B.PUSHR.R = continuous_command_for_PUSH(n)
#define PUSH_ENQ(n) DSPI_B.PUSHR.R = end_command_for_PUSH(n)
#define POP(n) n = (uint8_t) (DSPI_B.POPR.R); \
DSPI_B.SR.R = DSPI_SR_RFDF
void spi_flash_bulk_erase (void)
{
uint8_t status, dummy_var;
ALLOW_TRANSFER; // if previous command has set EOQ
PUSH_ENQ(WREN); // write enable command
WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;
POP(dummy_var); // discard one RxFIFO item
ALLOW_TRANSFER; // if previous command has set EOQ
PUSH_ENQ(BE); // bulk erase command
WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;
POP(dummy_var); // discard one RxFIFO item
printf("Beginning of Bulk Erase... (several tens of second)\n\r"); fflush(stdout);
do
{
status = spi_flash_read_status_register();
}
while (status & WIP); // wait here until bulk erase is done
printf("Bulk Erase Done !\n\r"); fflush(stdout);
}
Kindly explain in context if possible.
Regards,
Vignesh