During photosynthesis,
ATP is formed during phosphorylation. Water does take part in photosynthesis, oxygen comes from water not from CO2.