Reading and generating square waves at the same time.