A formal synthesis method for complex real-time embedded software is proposed in this work. Compared to previous work, our method not only synthesizes embedded software with complex interrelated branching choices for execution within a user-given memory bound, but also tries to guarantee the satisfaction of local and global time constraints. Our proposed method called Timed Quasi-Static Scheduling (TQSS) synthesizes real-time embedded software code from a set of Time Complex-Choice Petri Nets. The two most important issues in real-time embedded software, namely memory and time constraints are both elegantly and efficiently handled in TQSS. We show the feasibility of our method through a master-slave role switch application which is a part of the Bluetooth wireless communication protocol.