First off, sign on to your itunes connect and go to the app you want to generate the code for, then click the features option, then click the promo code option (currently located on the left panel).
Change the box to 1 where it says what number of codes do you want, then generate the code.
To use or redeem the iphone promo code you just generated, go into your itunes connect screen and click the history option. On the far right there is an option there to "view code". On your iphone open your appstore icon and go the "apps" section on the bottom, scroll it all the way down, and you will see a "redeem" button. Thats where you will enter your code and the app will automatically download.