Madelung constant calculation using Dmol3 or CASTEP?

Dear all, please can you guide me with an example how to calculate the Madelung constant using Dmol3 or CASTEP?