I've had no real trouble getting the PDCA working correctly with USARTs and SPI, both transmit and receive. But for the life of me, I'm not figuring out what needs to happen to use it with TWI.
First of all, the datasheet (page 228, section 24.11.1 and 24.11.2) talks about setting and checking handshaking bits in the PDC module (TXTEN, RXTEN, "end TX flag", "end RX flag", TXDIS, RXDIS) that simply don't seem to exist in the register documentation.
Second, for TWI receives, the datasheet talks about setting up the PDCA transfer size for size-1. (Datasheet's emphasis.) Does this actually mean that the PDCA transfer size needs to be 1 byte less than the total number of data bytes (presumably, excluding addressing) that I expect to transfer? Does that mean, if I were writing a driver that is meant to be able to deal with variable-length transfers, I would have to treat the case of a 1-byte transfer specially, and perform that transfer using polling or interrupts instead of DMA?
Finally, do I need to do anything special to kick off a TWI transfer using PDCA? Or does the simple act of activating the PDCA channel automatically trigger the TWI module to start the transmission?
Can anybody here who's successfully worked with TWI using the PDCA give me some pointers?
Thanks,
Luke