Since the early days of microcontrollers semiconductor vendors have provided example code to help their customers, but the range of quality of that code drastically varies.