# How to calculate energy of conduction band - fermi energy (Ec-Ef) - semiconductor

I am learning shottky diodes and i want to work out the built in potential barrier using:

$$V_{bi} = \phi_m - [E_c - E_f]$$

now i come across 2 equations when working out Ec-Ef.

the first:

$$E_c - E_f = \frac{kT}{q} ln(\frac{N_c}{N_d})$$ the second is $$E_c - E_f = \frac{Eg}{2} -[E_f-E_i]$$ where $$E_f - E_i = \frac{kT}{q} ln{\frac{N_d}{n_i}}$$

Which do i use?