If you want nanosecond accuracy in bit placement you should be using hardware. Try clocking bits via the SPI interface at a rate that matches your needs.
Tips, Buy me a coffee, or three.. PayPalVenmo Up vote any posts that you find helpful, it shows what's working..