ATP synthase generates ATP in mitochondria during cellular respiration, and in chloroplasts during photosynthesis.