Why did he say "Elokim"?
Radak: He calls to Him. He says, even though I am chased constantly, my heart is proper in me, and trusts in You to save me from their hands.
Malbim: This is when Sha'ul entered the cave, and David's men incited him to kill him. David strengthened himself against his Yetzer, and said "Nachon Libi Elokim" - my heart rules over my Nefesh. It is proper to overpower my Yetzer; I will not strike him.
Why did he repeat "Nachon Libi"?
Rashi: My heart is faithful with You [when You conduct with] Midas ha'Din; it is faithful with You [when You conduct with] Midas ha'Rachamim.
Radak: The repetition strengthens the matter.
Why did he say "Ashirah va'Azamerah"?
Radak: I trust that You will save me, and I will sing to You for this.
Malbim: I will sing that my heart stopped me from killing.