There might have been some water in your pan. Also, if your sugar had molasses, the amino acids in this might cause it. The fatter your cream is, the less likely it curdles. It also needs to be stirred in the pan. You can try to reheat your curdled caramel at a higher temperature and stirring continuously. A separated caramel is okay to eat but does look a bit grainy and not shiny. You might want to do a new batch as the cake icing.