Many microcontrollers have a timer feature that is designed to create a constant square wave output, the frequency of which is determined by how high the timer has ta count before resetting. If you look on the datasheet, there should be all the necessary information to configure the timer and calculate the correct values to get it to output the right frequency.