Although there are slight variations (depending on the source), the timeline surrounding the sin of the golden calf starts with Moshe ascending Mt. Sinai on the 7th of Sivan, staying there for 40 days and 40 nights, and descending with the first set of luchos (tablets)on the 17th of Tammuz, whereupon he saw the golden calf and broke the Luchos. The second (middle) set of 40 days began on the 18th or 19th of Tammuz, when Moshe went back up to ask for forgiveness, while the third set of 40 days started on the last day of Av or first day of Elul and ended on Yom Kippur, when Moshe came down with the second set of luchos.
We know that Moshe stayed on top of Mt. Sinai for the entire first set of 40 days (Shemos 24:18 and Devarim 9:9) and for the entire third set of 40 days (Shemos 34:28 and Devarim 10:10), but what about the middle set? Rashi (Shemos 18:13/33:11 and Devarim 9:18) says that Moshe was on top of Mt. Sinai for the entire middle set of 40 days too. Some Midrashim (e.g. Tanchuma Ki Sisa 31) and other commentators (e.g. Ramban on Shemos 33:7) also say that Moshe was on top of Mt. Sinai for all three sets of 40 days. There are several indications, though, that he wasn’t, at least not the entire time.
When the first and last sets of 40 days are mentioned, the Torah says explicitly that Moshe was on the mountain, whereas when the middle 40 days are referenced (Devarim 9:18 and 9:25), there’s no mention that he was there. Many discuss how each set of 40 days could contain a full 40 days and 40 nights on Mt. Sinai. After all, Moshe came down after the first set of 40 days with the first set of Luchos (Shemos 32:15 and Devarim 9:15), causing the clock to reset, and carved the second set of Luchos below before climbing back up for the third set of 40 days (Shemos 34:4 and Devarim 10:3), requiring another clock reset. If, however, the middle 40 days were not spent entirely atop Mt. Sinai, the clock could restart as soon as Moshe came down on the 17th of Tammuz, rather than when he went back up a day or two later, and these 40 days wouldn’t end until he went back up for the third set of 40 days, rather than when he came down to make the second set of Luchos (see Netziv on Shemos 32:30 and R’ Yaakov Emden on Seder Olam 6).
A straightforward reading of Moshe moving his tent outside the camp (Shemos 33:7-11) would have it occurring between the first and third sets of 40 days, in which case he couldn’t have been on top of Mt. Sinai for the entire middle set. Granted, Ramban (33:7) and Rashi (33:11, see Mizrachi) have most of this narrative occurring after Yom Kippur, with only the setting up of Moshe’s tent occurring right after the first set of 40 days. Still, this chronological adjustment (of 33:8-11) is only necessary if Moshe was atop Mt. Sinai for the entire middle set of 40 days; it flows much more easily if he wasn’t. Besides, why would Moshe call his tent “אהל מועד” (Tent of Meeting) (Shemos 33:7) if his intent was to convince God to allow the plan for the real אהל מועד (the Mishkan) to be reinstated, in which case he wouldn’t be using this one at all? If, on the other hand, he knew he was definitely going to use it, at least temporarily (because he wasn’t going to stay on top of the mountain), using the same term is understandable.
Pirkei d’Rabbi Eliezer 46 (see also Tanna Devei Eliyahu Zuta 4) has Moshe “in the camp” (rather than on the mountain) for the middle set of 40 days. The Vilna Gaon (Seder Olam 6, see also Shemos 33:18) agrees, and says that Moshe went up every day during those 40 days to pray, but came down after he finished praying. The Netziv (Shemos 32:30) says the same, adding (Devarim 9:25) that he went up to pray every day and every night, but returned afterwards. R’ Yaakov Emden (Seder Olam 6) is unsure whether Moshe went up to pray or prayed in his tent, but either way, most of his time (during the middle 40 days) was spent with the nation, in the camp below, trying to get them to repent.
——————————————
Moshe had to pray for the nation during the middle set of 40 days because God said He was going to destroy them (Devarim 9:25). Yet, despite these prayers being successful (9:19), Moshe told them (10:10) that after the prayers he offered during the third set of 40 days God no longer wanted to destroy them—implying that until then He was still planning to destroy them. (Some claim that 10:10 must therefore be referring to the middle set of 40 days—despite the context clearly indicating it was the third set—which would put Moshe on top of the mountain for the entire middle set too.) Since Moshe had successfully convinced God not to destroy the nation by the end of the middle set of 40 days (which is why the second set of Luchos were authorized), why would God still want to destroy them until the end of the third set of 40 days (on Yom Kippur)?
There are numerous approaches (see Ramban, Meshech Chochma and R’ Samson Raphael Hirsch on Devarim 10:10) explaining what God “no longer wanting to destroy them” after the third set of 40 days means (since Moshe’s prayers during the middle set were answered). The Netziv (Devarim 10:10, see 9:19) says it means that not only wouldn’t God destroy the entire nation, He wasn’t going to destroy even some of them. I would suggest that even though God had agreed not to destroy them after the second set of 40 days, it wasn’t because He had forgiven them, but because of the consequences of destroying them (as laid out by Moshe during his prayers, see Devarim 9:26-29). After the third set of 40 days, though, He no longer even “wanted” to destroy them because He had forgiven them.
Rabbi Dov Kramer published a short book (available on Amazon) trying to reconcile the narrative in Parashas Ki Sisa with the narrative in Parashas Eikev. A pdf of this long D’var Torah is available at RabbiDMK.wordpress.com.