I am attempting to write a SPI driver for the MK10DX256. The problem I am facing is that I cannot write to the SPI1_PUSHR register.
I have already looked at code examples from Processor Expert and referenced this blog post with no luck. https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-example-on-Kinetis-KL16/td-p/295652
The driver starts with an initialization function where I do the following:
SPI_MemMapPtr poSpiPort = SPI1_BASE_PTR;
SIM_SCGC6 |=SIM_SCGC6_SPI1_MASK;
SPI_MCR_REG(poSpiPort) |= SPI_MCR_MSTR_MASK |
SPI_MCR_DCONF(0x00)|
SPI_MCR_ROOE_MASK |
SPI_MCR_PCSIS(0x01)|
SPI_MCR_HALT_MASK;
SPI_MCR_REG(poSpiPort) |= SPI_MCR_CLR_TXF_MASK |
SPI_MCR_CLR_RXF_MASK;
SPI_CTAR_REG(poSpiPort, 0) = SPI_CTAR_FMSZ_MASK|
SPI_CTAR_BR(0x4);
SPI1_SR = SPI_SR_TCF_MASK |
SPI_SR_EOQF_MASK |
SPI_SR_TFUF_MASK |
SPI_SR_TFFF_MASK |
SPI_SR_RFOF_MASK |
SPI_SR_RFDF_MASK |
SPI_SR_TXCTR(0x00) |
SPI_SR_TXNXTPTR(0x00) |
SPI_SR_RXCTR(0x00) |
SPI_SR_POPNXTPTR(0x00) |
0x00200000U;
SPI1_RSER = SPI_RSER_RFDF_RE_MASK;
SPI1_MCR &= (uint32_t)~(uint32_t)(SPI_MCR_HALT_MASK);
SPI_PUSHR_REG(poSpiPort) |= SPI_PUSHR_CONT_MASK|
SPI_PUSHR_CTAS(0)|
SPI_PUSHR_PCS(0b00010)|
0x01;
In the last line of the code I am not able to update the PUSHR register. All of the previous register writes work. In Code Warrior in the debugger "Registers" view I can see all of the registers updating, except for the PUSHR register.
One indication that I have not set up the registers correctly is that the SR[TXRXS] flag is 0, indicating that the TX and RX operations are disabled (DSPI is in stopped state). I'm not sure why the flag is cleared because I have met all the requirements for transitioning to the Start state.
1. SR[EOQF] bit is clear
2. MCR[FRZ] bit is clear
3. MCR[HALT] bit is clear
Any help is appreciated!
Hello,
I recommend using the examples from the MK60 the module is similar to the MK10, and you can find more examples in the SDK Welcome | MCUXpresso SDK Builder (nxp.com).
Best regards,
Pavel
Hello, my name is Pavel, and I will be supporting your case, let me get into your case and when I have more information, I will contact you.
Best regards,
Pavel