Modify your ADC input circuit such that 300V is represented by 5V. I will then write a code for you. 0.6V for 245V is very less. You will get 0.44V for 180V.
Just drop the AC voltage to 6 or 7 volts and pass through half wave or bridge to get around 4.7 to 5V at adc input for AC 300V.