You have to go by the timeframe for Conventional (Freddie and Fannie) and FHA mortgages from discharge date.
If you filed Chapter 13, it 2 years from the discharge date for a conventional mortgage (Fannie and Freddie), and 1 year of satisfactory payment performance for FHA
If you filed Chapter 7, it is 4 years from the discharge date for Conventional mortgages and 2 years for FHA.
During these waiting periods, you have to have very strong credit, in other words, paying every bill, credit card, rent and installments on time, never a day late.
Save your money for as large of a down payment as possible. 20% or more down payment will help you also.