The answer to your question can be found in Chapter Fifteen of this great story. Remember that key to understanding this tale is that we witness the gradual coming of age and moral maturity of Huck, the central protagonist. The event you allude to marks a key moment in his moral growth, as he defies social conventions and customs and apologises to a runaway slave, admitting he was wrong and understanding how he hurt Jim in the process. For a white boy to do this to a runaway slave shows incredible force of character, as Huck was going against everything he had learnt and been taught in his upbringing. Note what Huck tells us about his apology:
It was fifteen minutes before I could work myself up to go and humble myself to a nigger; but I done it, and I warn't ever sorry for it afterwards, neither.
So, we can see that it took Huck fifteen minutes to resolve his inner conflict and follow his heart rather than his head.