
DocID024597 Rev 5
RM0351
Single Wire Protocol Master Interface (SWPMI)
1517
In the SWPMI interrupt routine, the user must check TXBEF bit in the SWPMI_ISR register.
If it is set, and if another frame needs to be transmitted, the user must:
1.
Disable stream or channel in DMA module
2. Update the buffer in the RAM memory with the content of the next frame to be sent
3. Configure the total number of words to be transferred in DMA module
4. Enable stream or channel in DMA module to start next frame transmission
5. Set CTXBEF bit in the SWPMI_ICR register to clear the TXBEF flag
Multi software buffer mode
This mode allows to work with several frame buffers in the RAM memory, in order to ensure
a continuous transmission, keeping a very low CPU load, and allowing more latency for
buffer update by software thanks to the DMA. The software can check the DMA counters at
any time and update SWP frames accordingly in the RAM memory.
The Multi software buffer mode must be used in combination with DMA in circular mode.
Each transmission buffer in the RAM memory must have a fixed length of eight 32-bit words,
whatever the number of bytes in the SWP frame payload. The transmission buffers in the
RAM memory must be filled by the software, keeping an offset of 8 between two
consecutive ones. The first data byte of the buffer is the number of bytes of the frame
payload. See the buffer example in
Figure 482: SWPMI Multi software buffer mode
The Multi software buffer mode is selected by setting both TXDMA and TXMODE bits in
SWPMI_CR register.
For example, in order to work with 4 transmission buffers, the user must configure the DMA
as follows:
The DMA channel or stream must be configured in following mode (refer to DMA section):
•
memory to memory mode disabled,
•
memory increment mode enabled,
•
memory size set to 32-bit,
•
peripheral size set to 32-bit,
•
peripheral increment mode disabled,
•
circular mode enabled,
•
data transfer direction set to read from memory,
•
the number of words to be transfered must be set to 32 (8 words per buffer),
•
the source address is the buffer1 in RAM,
•
the destination address is the SWPMI_TDR register.
Then, the user must:
1.
Set TXDMA in the SWPMI_CR register
2. Set TXBEIE in the SWPMI_IER register
3. Fill buffer1, buffer2, buffer3 and buffer4 in the RAM memory (with the number of data
bytes in the payload on the least significant byte of the first word)
4. Enable stream or channel in DMA module to start DMA.