Hi folks,
We’ve now had success getting NXP SPI hardware working with the ANT. I was a little surprised nobody had any feedback on this thread so far. Perhaps this just means nobody is doing what I’m doing (!) –regardless I thought I’d post some pointers on the hardware integration of ANT hardware with SPI ports to help anyone else doing a forum search. Specifically this relates to using the AP2 and NXP ARM7 processors, although I believe this information would be relevant to any ANT module in byte synchronous mode communicating with a true hardware SPI port.
First up, the AP2 does not speak native SPI. SPI is a de-facto standard, introduced by Motorola in the 68HC11. Implementations by other manufacturers have various extra features or variations, but ultimately two SPI devices can typically find common ground to communicate with just by hooking up the 4x SPI lines.
ANT byte synchronous mode shares the SPI concept of master/slave communications, a source clock, and separate lines for bi-directional data. It also shares mode 3 (CPHA=CPOL=1) of timing for the clock and serial lines.
Where it deviates from the norm is that the SEN line cannot be used for SPI’s SSEL as it is released at the beginning of the last byte in a transaction rather than one clock cycle after the last bit. By the SPI standard, the slave receiving this signal should immediately abandon the transaction and tri-state the MISO line. In practice this means that SPI hardware will not be able to send or receive the ANT protocol checksum byte with this configuration.
ANT also has some extra control signals that are needed for MCU and wake power wake states. These aren’t of any particular relevance to the SPI transactions other than providing a bit of control and handshaking that the MCU needs to deal with.
So, if it’s not fully SPI compatible, why did I want to make it work with an SPI port? Saving a UART was one thing, but also operating the ANT in Byte Synchronous mode provides the lowest MCU overhead interfacing mechanism because the driver can be completely interrupt driven, make use of the SPI bit shifting hardware engine, and free up clock cycles for other things (or sleeping!). While not important to me in my current application, the MCU only needs to be awake for the shortest possible times = low power in this mode. Bit Synchronous mode requires software bit-banging, which is really a last resort option.
Anyway, at the end of the day to make the ANT work with NXP’s SPI implementation means dealing with the SEN line. In my case I just connected SEN to a GPIO (rather than SSEL) and then used another GPIO to drive the SSEL line with the correct timing (i.e. de-asserting it when I read a byte from the shift register if SEN has already been de-asserted). This means now 8x lines are needed to implement the interface to the ANT. This would be 9x if you use the H/W reset line, although you don’t need this when using the synchronous Interface since you can achieve the same result with the SRDY and SMSGRDY lines.
To get full benefit of power saving states or saving CPU cycles with the NXP hardware I’d recommend connecting the SEN line to a GPIO (or other input such as a CAP, EINT etc) that generates interrupts that can wake the MCU from deep sleep.
Also the SRDY line needs to operate as “software controlled IO†(see page 29 of the nRFAP2 spec) which means a pulse of min 2.5us. You can save a few more cycles here by using a timer output pin for this.
One last point about the NXP SPI ports. These come in a couple of flavours that support different extensions. Of particular note, SPI[0]supports LSB ordering where SSP/SPI[1] or higher do not. So using SPI[0] means you can save some cycles doing bit reversal in software. The other differences aren’t of any particular note for ANT interfacing.
OK, hopefully that helps out anyone starting out with SPI.
For the ANT team, could I suggest that SPI nomenclature be cleaned up in the product specification and D00000794? I found this misleading and it would be better to say that the clock and data timing is consistent with SPI mode 3, but that extra control signaling for SSEL will need to be added by the integrator.
As a suggestion for future specifications, could a method for switching to compliant SPI signaling be added? Looking at how SRDY is being used, perhaps if SRDY is held low at the end of the first byte from the ANT master(rather than pulsed) then this could signal that the rest of transaction will be made SPI compliant? In practice I think this means that the ANT module would keep clocking bytes without waiting for SRDY, and release SEN after the last byte was clocked out. In addition to making the transmission SPI compliant, for MCU’s implementing SPI with a ring buffer this means they could sleep after the control byte and wake when SSEL is released at the end of the complete transaction, so more power/cycle savings.
Thanks and regards,
Brent.