I want to use a microcontroller from NXP to generate a SWD (Serial wire debug) serial signal. A SWD signal is a clock and a host to target header, a single cycle wait period, followed by either a host to target or a target to host reply. It looks ALMOST exactly like a I2C signal, but I need to be able to transfer more than 14 or 28 bits (I forget exactly) after the header is transfered. The docs for the NXP uC I looked at had a hard limit on the number of bits that could be transfered after the header data. A simple RS-232 could do it by connecting the data wire to both Rx and Tx, but I also need a clock line.
Generating a custom half duplex 1 wire serial protocal
i2cserialswd
Related Topic
- Electronic – 2C Master Stretch the clock
- Electronic – Serial comms over 3m cable, shared with USB
- Electronic – arduino – Serial data received in wrong bits
- Electrical – I2C slave compatible with SMBus protocol
- Electronic – i2c data rate calculation
- Electronic – Identify this open collector serial protcol
- Electronic – leave SWO/TDO and TDI of J-Link floating
Best Answer
It sounds like what you want is what is known as Bit Banging. This is where you use one or more general purpose IO lines to emulate something like I²C, SPI, RS232 or whatever else you like, purely using software.
While this gives you the ultimate in flexibility, it does tend to tie up the microcontroller while any transfers are going on.
If speed isn't too much of an issue you could tie the transfer of data to a timer interrupt - transferring 1 bit every 10µS or something.
So, transferring a bit with an active low clock would go something like: